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

Method test_hash_collision_concurrent_add

Lib/test/test_set.py:1910–1935  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1908 s.update(other)
1909
1910 def test_hash_collision_concurrent_add(self):
1911 class X:
1912 def __hash__(self):
1913 return 0
1914 class Y:
1915 flag = False
1916 def __hash__(self):
1917 return 0
1918 def __eq__(self, other):
1919 if not self.flag:
1920 self.flag = True
1921 s.add(X())
1922 return self is other
1923
1924 a = X()
1925 s = set()
1926 s.add(a)
1927 s.add(X())
1928 s.remove(a)
1929 # Now the set contains a dummy entry followed by an entry
1930 # for an object with hash 0.
1931 s.add(Y())
1932 # The following operations should not crash.
1933 repr(s)
1934 list(s)
1935 set() | s
1936
1937
1938class TestOperationsMutating:

Callers

nothing calls this directly

Calls 6

setFunction · 0.85
listClass · 0.85
XClass · 0.70
YClass · 0.70
addMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected