From cf327a2e2d4e2c504b5080fbf7bd48421fe7b4c7 Mon Sep 17 00:00:00 2001 From: melissaml Date: Sun, 5 Jul 2020 20:04:04 +0800 Subject: Switch from unittest2 compat methods to Python 3.x methods With the removal of Python 2.x we can remove the unittest2 compat wrappers and switch to assertCountEqual instead of assertItemsEqual We have been able to use them since then, because testtools required unittest2, which still included it. With testtools removing Python 2.7 support [3][4], we will lose support for assertItemsEqual, so we should switch to use assertCountEqual. [1] - https://bugs.python.org/issue17866 [2] - https://hg.python.org/cpython/rev/d9921cb6e3cd [3] - testing-cabal/testtools#286 [4] - testing-cabal/testtools#277 Change-Id: Iaa8251a1e9965a00fe99b7a740a104c011260340 --- taskflow/tests/unit/patterns/test_graph_flow.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'taskflow/tests/unit/patterns') diff --git a/taskflow/tests/unit/patterns/test_graph_flow.py b/taskflow/tests/unit/patterns/test_graph_flow.py index 8aab109..ef33f61 100644 --- a/taskflow/tests/unit/patterns/test_graph_flow.py +++ b/taskflow/tests/unit/patterns/test_graph_flow.py @@ -85,7 +85,7 @@ class GraphFlowTest(test.TestCase): f = gf.Flow('test').add(task1, task2) self.assertEqual(2, len(f)) - self.assertItemsEqual(f, [task1, task2]) + self.assertCountEqual(f, [task1, task2]) self.assertEqual([], list(f.iter_links())) def test_graph_flow_two_dependent_tasks(self): @@ -94,7 +94,7 @@ class GraphFlowTest(test.TestCase): f = gf.Flow('test').add(task1, task2) self.assertEqual(2, len(f)) - self.assertItemsEqual(f, [task1, task2]) + self.assertCountEqual(f, [task1, task2]) self.assertEqual([(task1, task2, {'reasons': set(['a'])})], list(f.iter_links())) @@ -107,7 +107,7 @@ class GraphFlowTest(test.TestCase): f = gf.Flow('test').add(task1).add(task2) self.assertEqual(2, len(f)) - self.assertItemsEqual(f, [task1, task2]) + self.assertCountEqual(f, [task1, task2]) self.assertEqual([(task1, task2, {'reasons': set(['a'])})], list(f.iter_links())) @@ -167,7 +167,7 @@ class GraphFlowTest(test.TestCase): self.assertEqual(3, len(f)) - self.assertItemsEqual(list(f.iter_links()), [ + self.assertCountEqual(list(f.iter_links()), [ (task1, task2, {'reasons': set(['a', 'b'])}), (task2, task3, {'reasons': set(['c'])}) ]) @@ -178,7 +178,7 @@ class GraphFlowTest(test.TestCase): f = gf.Flow('test').add(task1, task2) linked = f.link(task1, task2) self.assertIs(linked, f) - self.assertItemsEqual(list(f.iter_links()), [ + self.assertCountEqual(list(f.iter_links()), [ (task1, task2, {'manual': True}) ]) @@ -192,7 +192,7 @@ class GraphFlowTest(test.TestCase): 'manual': True, 'reasons': set(['a']) } - self.assertItemsEqual(list(f.iter_links()), [ + self.assertCountEqual(list(f.iter_links()), [ (task1, task2, expected_meta) ]) @@ -267,7 +267,7 @@ class TargetedGraphFlowTest(test.TestCase): f.add(task1, task2, task3, task4) f.set_target(task3) self.assertEqual(3, len(f)) - self.assertItemsEqual(f, [task1, task2, task3]) + self.assertCountEqual(f, [task1, task2, task3]) self.assertNotIn('c', f.provides) def test_targeted_flow_reset(self): @@ -280,7 +280,7 @@ class TargetedGraphFlowTest(test.TestCase): f.set_target(task3) f.reset_target() self.assertEqual(4, len(f)) - self.assertItemsEqual(f, [task1, task2, task3, task4]) + self.assertCountEqual(f, [task1, task2, task3, task4]) self.assertIn('c', f.provides) def test_targeted_flow_bad_target(self): @@ -297,7 +297,7 @@ class TargetedGraphFlowTest(test.TestCase): f.add(task1) f.set_target(task1) self.assertEqual(1, len(f)) - self.assertItemsEqual(f, [task1]) + self.assertCountEqual(f, [task1]) def test_recache_on_add(self): f = gf.TargetedFlow("test") -- cgit v1.2.1