Skip to content

Commit

Permalink
Split test and fix warning
Browse files Browse the repository at this point in the history
message is deprecated.
  • Loading branch information
hynek committed Feb 2, 2019
1 parent 40edb30 commit 3421b4b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions tests/test_dunders.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,17 +496,20 @@ def assert_hash_code_not_cached_across_serialization(original):
HashCacheSerializationTestCachedSlots()
)

# Test that a custom __setstate__ is disallowed on a
# cache_hash=True object.
# This is needed because we handle clearing the cache after
# deserialization with a custom __setstate__. It is possible
# to make both work, but it requires some thought about how to go
# about it, so it has not yet been implemented.
def test_caching_and_custom_setstate(self):
"""
The combination of a custom __setstate__ and cache_hash=True is caught
with a helpful message.
This is needed because we handle clearing the cache after
deserialization with a custom __setstate__. It is possible to make both
work, but it requires some thought about how to go about it, so it has
not yet been implemented.
"""
with pytest.raises(
NotImplementedError,
message="Currently you cannot use hash caching if you "
"specify your own __setstate__ method. This is tracked"
"by https://github.com/python-attrs/attrs/issues/494",
match="Currently you cannot use hash caching if you "
"specify your own __setstate__ method.",
):

@attr.attrs(hash=True, cache_hash=True)
Expand Down

0 comments on commit 3421b4b

Please sign in to comment.