diff options
author | Petr Viktorin <pviktori@redhat.com> | 2015-09-18 11:30:15 +0200 |
---|---|---|
committer | Tomas Babej <tbabej@redhat.com> | 2015-10-13 14:16:32 +0200 |
commit | 59d87d53b10a201ef03077c96011523bdd1342e8 (patch) | |
tree | d72834017dfef90e107cf3093beee9ede07a836b /ipatests | |
parent | 5ff4170ff9cab64d3527001de8214cb30439e3e3 (diff) | |
download | freeipa-59d87d53b10a201ef03077c96011523bdd1342e8.tar.gz freeipa-59d87d53b10a201ef03077c96011523bdd1342e8.tar.xz freeipa-59d87d53b10a201ef03077c96011523bdd1342e8.zip |
Do not compare types that are not comparable in Python 3
In Python 3, different types are generally not comparable (except for equality),
and None can't be compared to None.
Fix cases of these comparisons.
In ipatest.util, give up on sorting lists if the sorting raises a TypeError.
Reviewed-By: Tomas Babej <tbabej@redhat.com>
Diffstat (limited to 'ipatests')
-rw-r--r-- | ipatests/test_ipapython/test_ipautil.py | 2 | ||||
-rw-r--r-- | ipatests/util.py | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/ipatests/test_ipapython/test_ipautil.py b/ipatests/test_ipapython/test_ipautil.py index 609e1f0e5..e19cd2cb6 100644 --- a/ipatests/test_ipapython/test_ipautil.py +++ b/ipatests/test_ipapython/test_ipautil.py @@ -321,7 +321,7 @@ class TestCIDict(object): def test_fromkeys(self): dct = ipautil.CIDict.fromkeys(('A', 'b', 'C')) assert sorted(dct.keys()) == sorted(['A', 'b', 'C']) - assert sorted(dct.values()) == [None] * 3 + assert list(dct.values()) == [None] * 3 class TestTimeParser(object): diff --git a/ipatests/util.py b/ipatests/util.py index d180c91b7..85b5dbc5e 100644 --- a/ipatests/util.py +++ b/ipatests/util.py @@ -331,8 +331,14 @@ def assert_deepequal(expected, got, doc='', stack=tuple()): s_got = got s_expected = expected else: - s_got = sorted(got) - s_expected = sorted(expected) + try: + s_got = sorted(got) + except TypeError: + s_got = got + try: + s_expected = sorted(expected) + except TypeError: + s_expected = expected for (i, e_sub) in enumerate(s_expected): g_sub = s_got[i] assert_deepequal(e_sub, g_sub, doc, stack + (i,)) |