Skip to content

Commit

Permalink
bump lower bound on version for order expectation
Browse files Browse the repository at this point in the history
  • Loading branch information
vreuter committed May 14, 2019
1 parent bafbea5 commit f923828
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion attmap/ordattmap.py
Expand Up @@ -30,7 +30,8 @@ def __delitem__(self, key):
_LOGGER.debug(safedel_message(key))

def __eq__(self, other):
return AttMap.__eq__(self, other) and list(self.keys()) == list(other.keys())
return AttMap.__eq__(self, other) and \
list(self.keys()) == list(other.keys())

def __ne__(self, other):
return not self == other
Expand Down
8 changes: 6 additions & 2 deletions tests/test_ordattmap.py
Expand Up @@ -118,19 +118,23 @@ def test_ordattmap_deletion(hwy_dat_key, raw_hwy_dat, alter, check):
@pytest.mark.parametrize("base_type", [OrdAttMap, OrdPathExAttMap])
@pytest.mark.parametrize(
["that_type", "final_exp"],
[(dict, sys.version_info >= (3, 5)), (OrderedDict, True), (OrdAttMap, True)])
[(dict, sys.version_info >= (3, 6)), (OrderedDict, True), (OrdAttMap, True)])
def test_ordattmap_overrides_eq_exclusion(
hwy_dat_key, raw_hwy_dat, base_type, that_type, final_exp):
""" Verify ability to exclude key from comparisons. """
class OrdSub(base_type):
def _excl_from_eq(self, k):
return super(OrdSub, self)._excl_from_eq(k) or k == hwy_dat_key
print("Considering for exclusion: {}".format(k))
res = super(OrdSub, self)._excl_from_eq(k) or k == hwy_dat_key
print("Exclude: {}".format(res))
return res
msub = OrdSub(raw_hwy_dat)
assert isinstance(msub, OrdAttMap)
that = that_type(raw_hwy_dat)
assert msub != that
assert msub == OrdSub(raw_hwy_dat)
msub[hwy_dat_key] = None
assert msub[hwy_dat_key] is None
assert list(msub.items()) != list(that.items())
assert msub != that
assert (msub == OrdSub(that.items())) is final_exp
Expand Down

0 comments on commit f923828

Please sign in to comment.