mirror of https://github.com/jab/bidict.git
fix test
This commit is contained in:
parent
5cc0af2623
commit
d57bae234f
|
@ -70,8 +70,11 @@ not_bidicts = (
|
||||||
@pytest.mark.parametrize('b, other', product(bidicts, bidicts + not_bidicts))
|
@pytest.mark.parametrize('b, other', product(bidicts, bidicts + not_bidicts))
|
||||||
def test_eq_and_hash(b, other):
|
def test_eq_and_hash(b, other):
|
||||||
"""Make sure equality tests and hash results behave as expected."""
|
"""Make sure equality tests and hash results behave as expected."""
|
||||||
|
b_has_eq_order_sens = hasattr(b, 'equals_order_sensitive')
|
||||||
if not isinstance(other, Mapping):
|
if not isinstance(other, Mapping):
|
||||||
assert b != other
|
assert b != other
|
||||||
|
if b_has_eq_order_sens:
|
||||||
|
assert not b.equals_order_sensitive(other)
|
||||||
elif len(b) != len(other):
|
elif len(b) != len(other):
|
||||||
assert b != other
|
assert b != other
|
||||||
else:
|
else:
|
||||||
|
@ -81,9 +84,7 @@ def test_eq_and_hash(b, other):
|
||||||
both_hashable = isinstance(b, Hashable) and isinstance(other, Hashable)
|
both_hashable = isinstance(b, Hashable) and isinstance(other, Hashable)
|
||||||
if are_equal and both_hashable:
|
if are_equal and both_hashable:
|
||||||
assert hash(b) == hash(other)
|
assert hash(b) == hash(other)
|
||||||
|
if b_has_eq_order_sens:
|
||||||
if hasattr(b, 'equals_order_sensitive'):
|
|
||||||
are_equal_ordered = b.equals_order_sensitive(other)
|
are_equal_ordered = b.equals_order_sensitive(other)
|
||||||
should_be_equal_ordered = OrderedDict(b) == (
|
should_be_equal_ordered = OrderedDict(b) == OrderedDict(other)
|
||||||
OrderedDict(other) if isinstance(other, Mapping) else other)
|
|
||||||
assert are_equal_ordered == should_be_equal_ordered
|
assert are_equal_ordered == should_be_equal_ordered
|
||||||
|
|
Loading…
Reference in New Issue