MCPcopy Index your code
hub / github.com/python/cpython / Bad

Class Bad

Lib/test/test_set.py:1945–1955  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1943
1944 def make_sets_of_bad_objects(self):
1945 class Bad:
1946 def __eq__(self, other):
1947 if not enabled:
1948 return False
1949 if randrange(20) == 0:
1950 set1.clear()
1951 if randrange(20) == 0:
1952 set2.clear()
1953 return bool(randrange(2))
1954 def __hash__(self):
1955 return randrange(2)
1956 # Don't behave poorly during construction.
1957 enabled = False
1958 set1 = self.constructor1(Bad() for _ in range(randrange(50)))

Callers 1

Calls

no outgoing calls

Tested by 1