6
6
import time
7
7
import unittest
8
8
import weakref
9
+ from test .support import threading_helper
9
10
10
11
try :
11
12
from _testcapi import hamt
@@ -379,6 +380,7 @@ def ctx2_fun():
379
380
# TODO: RUSTPYTHON
380
381
@unittest .expectedFailure
381
382
@isolated_context
383
+ @threading_helper .requires_working_threading ()
382
384
def test_context_threads_1 (self ):
383
385
cvar = contextvars .ContextVar ('cvar' )
384
386
@@ -396,12 +398,6 @@ def sub(num):
396
398
tp .shutdown ()
397
399
self .assertEqual (results , list (range (10 )))
398
400
399
- # TODO: RUSTPYTHON
400
- @unittest .expectedFailure
401
- def test_contextvar_getitem (self ):
402
- clss = contextvars .ContextVar
403
- self .assertEqual (clss [str ], clss )
404
-
405
401
406
402
# HAMT Tests
407
403
@@ -577,6 +573,41 @@ def test_hamt_collision_1(self):
577
573
self .assertEqual (len (h4 ), 2 )
578
574
self .assertEqual (len (h5 ), 3 )
579
575
576
+ def test_hamt_collision_3 (self ):
577
+ # Test that iteration works with the deepest tree possible.
578
+ # https://github.com/python/cpython/issues/93065
579
+
580
+ C = HashKey (0b10000000_00000000_00000000_00000000 , 'C' )
581
+ D = HashKey (0b10000000_00000000_00000000_00000000 , 'D' )
582
+
583
+ E = HashKey (0b00000000_00000000_00000000_00000000 , 'E' )
584
+
585
+ h = hamt ()
586
+ h = h .set (C , 'C' )
587
+ h = h .set (D , 'D' )
588
+ h = h .set (E , 'E' )
589
+
590
+ # BitmapNode(size=2 count=1 bitmap=0b1):
591
+ # NULL:
592
+ # BitmapNode(size=2 count=1 bitmap=0b1):
593
+ # NULL:
594
+ # BitmapNode(size=2 count=1 bitmap=0b1):
595
+ # NULL:
596
+ # BitmapNode(size=2 count=1 bitmap=0b1):
597
+ # NULL:
598
+ # BitmapNode(size=2 count=1 bitmap=0b1):
599
+ # NULL:
600
+ # BitmapNode(size=2 count=1 bitmap=0b1):
601
+ # NULL:
602
+ # BitmapNode(size=4 count=2 bitmap=0b101):
603
+ # <Key name:E hash:0>: 'E'
604
+ # NULL:
605
+ # CollisionNode(size=4 id=0x107a24520):
606
+ # <Key name:C hash:2147483648>: 'C'
607
+ # <Key name:D hash:2147483648>: 'D'
608
+
609
+ self .assertEqual ({k .name for k in h .keys ()}, {'C' , 'D' , 'E' })
610
+
580
611
def test_hamt_stress (self ):
581
612
COLLECTION_SIZE = 7000
582
613
TEST_ITERS_EVERY = 647
0 commit comments