bugfix for unhashable/uncomparable dicts
This commit is contained in:
parent
5575789612
commit
7960a29252
14
mox.py
14
mox.py
|
@ -1642,15 +1642,15 @@ class SameElementsAs(Comparator):
|
|||
return False
|
||||
|
||||
try:
|
||||
expected = dict([(element, None) for element in self._expected_list])
|
||||
actual = dict([(element, None) for element in actual_list])
|
||||
return set(self._expected_list) == set(actual_list)
|
||||
except TypeError:
|
||||
# Fall back to slower list-compare if any of the objects are unhashable.
|
||||
expected = self._expected_list
|
||||
actual = actual_list
|
||||
expected.sort()
|
||||
actual.sort()
|
||||
return expected == actual
|
||||
if len(self._expected_list) != len(actual_list):
|
||||
return False
|
||||
for el in actual_list:
|
||||
if el not in self._expected_list:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __repr__(self):
|
||||
return '<sequence with same elements as \'%s\'>' % self._expected_list
|
||||
|
|
Loading…
Reference in New Issue