Sort lists so order is predictable and tests pass as expected.

Related to https://fedorahosted.org/freeipa/ticket/1272
This commit is contained in:
Rob Crittenden
2011-08-30 23:40:17 -04:00
committed by Martin Kosek
parent d05ace8fba
commit 8f5e82940f
2 changed files with 7 additions and 5 deletions

View File

@@ -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

View File

@@ -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)