From 27656da5880d4314ced5fc61c1659870816e78bf Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Tue, 13 Mar 2018 09:32:04 -0400 Subject: [PATCH] test_fingerprint_order: work around dict items representation In Python 3, the order of a dictionary items will be different than under Python 2. To not have to change the supporting code to return OrderedDicts, let's just simplify the comparison, breaking them down into each dictionary item. This fixes the varianter_yaml_to_mux plugin unittest failure under Python 3: ====================================================================== FAIL: test_fingerprint_order (tests.test_mux.TestMuxTree) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/cleber/src/avocado/avocado/optional_plugins/varianter_yaml_to_mux/tests/test_mux.py", line 231, in test_fingerprint_order self.assertEqual(str(variant1), "{'paths': '', 'variant': " AssertionError: "{'variant_id': 'child1-child2-9154', 'varia[65 chars] ''}" != "{'paths': '', 'variant': [TreeNode(name='ch[65 chars]54'}" - {'variant_id': 'child1-child2-9154', 'variant': [TreeNode(name='child1'), TreeNode(name='child2')], 'paths': ''} + {'paths': '', 'variant': [TreeNode(name='child1'), TreeNode(name='child2')], 'variant_id': 'child1-child2-9154'} Signed-off-by: Cleber Rosa --- .../varianter_yaml_to_mux/tests/test_mux.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/optional_plugins/varianter_yaml_to_mux/tests/test_mux.py b/optional_plugins/varianter_yaml_to_mux/tests/test_mux.py index 16ba8324..f8c102b9 100644 --- a/optional_plugins/varianter_yaml_to_mux/tests/test_mux.py +++ b/optional_plugins/varianter_yaml_to_mux/tests/test_mux.py @@ -228,9 +228,18 @@ class TestMuxTree(unittest.TestCase): variant1 = next(iter(mux1)) variant2 = next(iter(mux2)) self.assertNotEqual(variant1, variant2) - self.assertEqual(str(variant1), "{'paths': '', 'variant': " - "[TreeNode(name='child1'), TreeNode(name=" - "'child2')], 'variant_id': 'child1-child2-9154'}") + str_variant = str(variant1) + variant_list = [] + for item in variant1: + variant_list.append("'%s': '%s'" % (item, variant1[item])) + expected_items = ["'paths': ''", + "'variant': '[TreeNode(name='child1'), " + "TreeNode(name='child2')]'", + "'variant_id': 'child1-child2-9154'"] + for item in expected_items: + self.assertIn(item, variant_list) + variant_list.remove(item) + self.assertFalse(variant_list) class TestMultiplex(unittest.TestCase): -- GitLab