@@ -418,44 +418,46 @@ def test_var_annot_simple_exec(self):
418
418
gns ['__annotations__' ]
419
419
420
420
# TODO: RUSTPYTHON
421
- # def test_var_annot_custom_maps(self):
422
- # # tests with custom locals() and __annotations__
423
- # ns = {'__annotations__': CNS()}
424
- # exec('X: int; Z: str = "Z"; (w): complex = 1j', ns)
425
- # self.assertEqual(ns['__annotations__']['x'], int)
426
- # self.assertEqual(ns['__annotations__']['z'], str)
427
- # with self.assertRaises(KeyError):
428
- # ns['__annotations__']['w']
429
- # nonloc_ns = {}
430
- # class CNS2:
431
- # def __init__(self):
432
- # self._dct = {}
433
- # def __setitem__(self, item, value):
434
- # nonlocal nonloc_ns
435
- # self._dct[item] = value
436
- # nonloc_ns[item] = value
437
- # def __getitem__(self, item):
438
- # return self._dct[item]
439
- # exec('x: int = 1', {}, CNS2())
440
- # self.assertEqual(nonloc_ns['__annotations__']['x'], int)
421
+ @unittest .expectedFailure
422
+ def test_var_annot_custom_maps (self ):
423
+ # tests with custom locals() and __annotations__
424
+ ns = {'__annotations__' : CNS ()}
425
+ exec ('X: int; Z: str = "Z"; (w): complex = 1j' , ns )
426
+ self .assertEqual (ns ['__annotations__' ]['x' ], int )
427
+ self .assertEqual (ns ['__annotations__' ]['z' ], str )
428
+ with self .assertRaises (KeyError ):
429
+ ns ['__annotations__' ]['w' ]
430
+ nonloc_ns = {}
431
+ class CNS2 :
432
+ def __init__ (self ):
433
+ self ._dct = {}
434
+ def __setitem__ (self , item , value ):
435
+ nonlocal nonloc_ns
436
+ self ._dct [item ] = value
437
+ nonloc_ns [item ] = value
438
+ def __getitem__ (self , item ):
439
+ return self ._dct [item ]
440
+ exec ('x: int = 1' , {}, CNS2 ())
441
+ self .assertEqual (nonloc_ns ['__annotations__' ]['x' ], int )
441
442
442
443
# TODO: RUSTPYTHON
443
- # def test_var_annot_refleak(self):
444
- # # complex case: custom locals plus custom __annotations__
445
- # # this was causing refleak
446
- # cns = CNS()
447
- # nonloc_ns = {'__annotations__': cns}
448
- # class CNS2:
449
- # def __init__(self):
450
- # self._dct = {'__annotations__': cns}
451
- # def __setitem__(self, item, value):
452
- # nonlocal nonloc_ns
453
- # self._dct[item] = value
454
- # nonloc_ns[item] = value
455
- # def __getitem__(self, item):
456
- # return self._dct[item]
457
- # exec('X: str', {}, CNS2())
458
- # self.assertEqual(nonloc_ns['__annotations__']['x'], str)
444
+ @unittest .expectedFailure
445
+ def test_var_annot_refleak (self ):
446
+ # complex case: custom locals plus custom __annotations__
447
+ # this was causing refleak
448
+ cns = CNS ()
449
+ nonloc_ns = {'__annotations__' : cns }
450
+ class CNS2 :
451
+ def __init__ (self ):
452
+ self ._dct = {'__annotations__' : cns }
453
+ def __setitem__ (self , item , value ):
454
+ nonlocal nonloc_ns
455
+ self ._dct [item ] = value
456
+ nonloc_ns [item ] = value
457
+ def __getitem__ (self , item ):
458
+ return self ._dct [item ]
459
+ exec ('X: str' , {}, CNS2 ())
460
+ self .assertEqual (nonloc_ns ['__annotations__' ]['x' ], str )
459
461
460
462
461
463
def test_var_annot_rhs (self ):
0 commit comments