Update test_context from Cpython v3.11.2 by Masorubka1 · Pull Request #4805 · RustPython/RustPython
try: from _testcapi import hamt
# TODO: RUSTPYTHON @unittest.expectedFailure def test_contextvar_getitem(self): clss = contextvars.ContextVar self.assertEqual(clss[str], clss)
# HAMT Tests
def test_hamt_collision_3(self): # Test that iteration works with the deepest tree possible. # https://github.com/python/cpython/issues/93065
C = HashKey(0b10000000_00000000_00000000_00000000, 'C') D = HashKey(0b10000000_00000000_00000000_00000000, 'D')
E = HashKey(0b00000000_00000000_00000000_00000000, 'E')
h = hamt() h = h.set(C, 'C') h = h.set(D, 'D') h = h.set(E, 'E')
# BitmapNode(size=2 count=1 bitmap=0b1): # NULL: # BitmapNode(size=2 count=1 bitmap=0b1): # NULL: # BitmapNode(size=2 count=1 bitmap=0b1): # NULL: # BitmapNode(size=2 count=1 bitmap=0b1): # NULL: # BitmapNode(size=2 count=1 bitmap=0b1): # NULL: # BitmapNode(size=2 count=1 bitmap=0b1): # NULL: # BitmapNode(size=4 count=2 bitmap=0b101): # <Key name:E hash:0>: 'E' # NULL: # CollisionNode(size=4 id=0x107a24520): # <Key name:C hash:2147483648>: 'C' # <Key name:D hash:2147483648>: 'D'
self.assertEqual({k.name for k in h.keys()}, {'C', 'D', 'E'})
def test_hamt_stress(self): COLLECTION_SIZE = 7000 TEST_ITERS_EVERY = 647