from hypothesis import given, strategies as st class Probe: def __init__(self, value): self.value = value self.count = 0 def __hash__(self): return hash(self.value) def __eq__(self, other): self.count += 1 return other is self @given(st.text()) def test_str(value): probe = Probe(value) assert value not in {probe} assert probe.count == 1 @given(st.integers()) def test_int(value): probe = Probe(value) assert value not in {probe} assert probe.count == 1