From 18149fadb6a78a736d434634939074ea34bee79b Mon Sep 17 00:00:00 2001 From: Ana Krivokapic Date: Mon, 15 Apr 2013 15:15:02 +0200 Subject: Do not sort dictionaries in assert_deepequal utility function Sorting lists of dictionaries in assert_deepequal was causing inconsistencies in unit test execution. To fix this, do not sort lists if their elements are dictionaries. https://fedorahosted.org/freeipa/ticket/3562 --- tests/test_xmlrpc/test_netgroup_plugin.py | 12 ++++++------ tests/util.py | 9 +++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/test_xmlrpc/test_netgroup_plugin.py b/tests/test_xmlrpc/test_netgroup_plugin.py index 7a0dc5fa..ee826b75 100644 --- a/tests/test_xmlrpc/test_netgroup_plugin.py +++ b/tests/test_xmlrpc/test_netgroup_plugin.py @@ -464,12 +464,6 @@ class test_netgroup(Declarative): truncated=False, summary=u'2 netgroups matched', result=[ - { - 'dn': fuzzy_netgroupdn, - 'cn': [netgroup2], - 'description': [u'Test netgroup 2'], - 'nisdomainname': [u'%s' % api.env.domain], - }, { 'dn': fuzzy_netgroupdn, 'memberhost_host': (host1,), @@ -478,6 +472,12 @@ class test_netgroup(Declarative): 'description': [u'Test netgroup 1'], 'nisdomainname': [u'%s' % api.env.domain], }, + { + 'dn': fuzzy_netgroupdn, + 'cn': [netgroup2], + 'description': [u'Test netgroup 2'], + 'nisdomainname': [u'%s' % api.env.domain], + }, ], ), ), diff --git a/tests/util.py b/tests/util.py index ed62a223..117d2c83 100644 --- a/tests/util.py +++ b/tests/util.py @@ -316,8 +316,13 @@ def assert_deepequal(expected, got, doc='', stack=tuple()): raise AssertionError( LEN % (doc, len(expected), len(got), expected, got, stack) ) - s_got = sorted(got) - s_expected = sorted(expected) + # Sort list elements, unless they are dictionaries + if expected and isinstance(expected[0], dict): + s_got = got + s_expected = expected + else: + s_got = sorted(got) + s_expected = sorted(expected) for (i, e_sub) in enumerate(s_expected): g_sub = s_got[i] assert_deepequal(e_sub, g_sub, doc, stack + (i,)) -- cgit