spacepaste

  1.  
  2. from hypothesis import given, strategies as st
  3. class Probe:
  4. def __init__(self, value):
  5. self.value = value
  6. self.count = 0
  7. def __hash__(self):
  8. return hash(self.value)
  9. def __eq__(self, other):
  10. self.count += 1
  11. return other is self
  12. @given(st.text())
  13. def test_str(value):
  14. probe = Probe(value)
  15. assert value not in {probe}
  16. assert probe.count == 1
  17. @given(st.integers())
  18. def test_int(value):
  19. probe = Probe(value)
  20. assert value not in {probe}
  21. assert probe.count == 1
  22.