Skip to content

Commit

Permalink
Remove missed hashes in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Aug 3, 2024
1 parent bde3f58 commit 6e51cb7
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions tests/test_dunders.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ def test_enforces_type(self):
exc_args = ("Invalid value for hash. Must be True, False, or None.",)

with pytest.raises(TypeError) as e:
make_class("C", {}, hash=1),
make_class("C", {}, unsafe_hash=1),

assert exc_args == e.value.args

Expand All @@ -501,13 +501,18 @@ def test_enforce_no_cache_hash_without_hash(self):
"enabled.",
)
with pytest.raises(TypeError) as e:
make_class("C", {}, hash=False, cache_hash=True)
make_class("C", {}, unsafe_hash=False, cache_hash=True)
assert exc_args == e.value.args

# unhashable case
with pytest.raises(TypeError) as e:
make_class(
"C", {}, hash=None, eq=True, frozen=False, cache_hash=True
"C",
{},
unsafe_hash=None,
eq=True,
frozen=False,
cache_hash=True,
)
assert exc_args == e.value.args

Expand All @@ -521,7 +526,7 @@ def test_enforce_no_cached_hash_without_init(self):
" init must be True.",
)
with pytest.raises(TypeError) as e:
make_class("C", {}, init=False, hash=True, cache_hash=True)
make_class("C", {}, init=False, unsafe_hash=True, cache_hash=True)
assert exc_args == e.value.args

@given(booleans(), booleans())
Expand All @@ -533,7 +538,7 @@ def test_hash_attribute(self, slots, cache_hash):
"C",
{"a": attr.ib(hash=False), "b": attr.ib()},
slots=slots,
hash=True,
unsafe_hash=True,
cache_hash=cache_hash,
)

Expand Down Expand Up @@ -629,13 +634,13 @@ def __hash__(self):
Uncached = make_class(
"Uncached",
{"hash_counter": attr.ib(factory=HashCounter)},
hash=True,
unsafe_hash=True,
cache_hash=False,
)
Cached = make_class(
"Cached",
{"hash_counter": attr.ib(factory=HashCounter)},
hash=True,
unsafe_hash=True,
cache_hash=True,
)

Expand Down

0 comments on commit 6e51cb7

Please sign in to comment.