Skip to content

Commit

Permalink
Support non-weakrefable types
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Jul 3, 2022
1 parent 5a4ef42 commit 6a3f890
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions hypothesis-python/RELEASE.rst
@@ -0,0 +1,4 @@
RELEASE_TYPE: patch

:func:`hypothesis.event` now works for hashable objects which do not
support weakrefs, such as integers and tuples.
Expand Up @@ -1067,10 +1067,13 @@ def event_to_string(self, event):
return event
try:
return self.events_to_strings[event]
except KeyError:
except (KeyError, TypeError):
pass
result = str(event)
self.events_to_strings[event] = result
try:
self.events_to_strings[event] = result
except TypeError:
pass
return result


Expand Down
5 changes: 5 additions & 0 deletions hypothesis-python/tests/cover/test_statistical_events.py
Expand Up @@ -254,3 +254,8 @@ def test(value):
stats = describe_statistics(call_for_statistics(test))
assert "- Events:" in stats
assert "- Highest target score: " in stats


@given(st.booleans())
def test_event_with_non_weakrefable_keys(b):
event((b,))

0 comments on commit 6a3f890

Please sign in to comment.