mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-27 00:26:33 -06:00
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>
This commit is contained in:
parent
5ff4170ff9
commit
59d87d53b1
@ -1157,9 +1157,9 @@ class Decimal(Number):
|
||||
|
||||
super(Decimal, self).__init__(name, *rules, **kw)
|
||||
|
||||
if (self.minvalue > self.maxvalue) \
|
||||
and (self.minvalue is not None and \
|
||||
self.maxvalue is not None):
|
||||
if (self.minvalue is not None and
|
||||
self.maxvalue is not None and
|
||||
self.minvalue > self.maxvalue):
|
||||
raise ValueError(
|
||||
'%s: minvalue > maxvalue (minvalue=%s, maxvalue=%s)' % (
|
||||
self.nice, self.minvalue, self.maxvalue)
|
||||
|
@ -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):
|
||||
|
@ -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,))
|
||||
|
Loading…
Reference in New Issue
Block a user