JR ran into an issue with his automember patch where the order of memberof wasn't predictable which caused tests to fail.

To resolve this we just need to sort the lists and then compare.

rob
>From 4dddfe9d4166cba309ae213967f10f1d45d36b46 Mon Sep 17 00:00:00 2001
From: Rob Crittenden <rcrit...@redhat.com>
Date: Tue, 30 Aug 2011 23:40:17 -0400
Subject: [PATCH 1/2] Sort lists so order is predictable and tests pass as expected.

Related to https://fedorahosted.org/freeipa/ticket/1272
---
 tests/test_util.py |    4 ++--
 tests/util.py      |    8 +++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/tests/test_util.py b/tests/test_util.py
index 0a253adfa4ddd731a3f7b647a6d9f2bf7626635d..f87822a223f017f54f8b3bf5f6319b66e97482a7 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -180,7 +180,7 @@ def test_assert_deepequal():
     ]
     e = raises(AssertionError, f, a, b, 'foo')
     assert str(e) == TYPE % (
-        'foo', unicode, str, u'hello', 'hello', (0,)
+        'foo', unicode, str, u'hello', 'hello', (2,)
     )
 
     b = [
@@ -200,7 +200,7 @@ def test_assert_deepequal():
     ]
     e = raises(AssertionError, f, a, b, 'foo')
     assert str(e) == TYPE % (
-        'foo', int, float, 18, 18.0, (2,)
+        'foo', int, float, 18, 18.0, (0,)
     )
 
     # List length mismatch
diff --git a/tests/util.py b/tests/util.py
index 48260dd7cd06e9053a510cfec9ea592461c56da7..5a365fbcd0e065b2f645b379b554b973d511c791 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -286,7 +286,7 @@ def assert_deepequal(expected, got, doc='', stack=tuple()):
       type(got) = <type 'str'>
       expected = u'how are you?'
       got = 'how are you?'
-      path = (1, 'world')
+      path = (0, 'world')
     """
     if isinstance(expected, tuple):
         expected = list(expected)
@@ -301,8 +301,10 @@ def assert_deepequal(expected, got, doc='', stack=tuple()):
             raise AssertionError(
                 LEN % (doc, len(expected), len(got), expected, got, stack)
             )
-        for (i, e_sub) in enumerate(expected):
-            g_sub = got[i]
+        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,))
     elif isinstance(expected, dict):
         missing = set(expected).difference(got)
-- 
1.7.4

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to