@@ -349,7 +349,7 @@ def test_empty(self):
349
349
def test_no_eval_union (self ):
350
350
u = Union [int , str ]
351
351
def f (x : u ): ...
352
- self .assertIs (get_type_hints (f )['x' ], u )
352
+ self .assertIs (get_type_hints (f , globals (), locals () )['x' ], u )
353
353
354
354
def test_function_repr_union (self ):
355
355
def fun () -> int : ...
@@ -2853,7 +2853,7 @@ def test_get_type_hints_classes(self):
2853
2853
{'x' : int , 'y' : int })
2854
2854
self .assertEqual (gth (mod_generics_cache .B ),
2855
2855
{'my_inner_a1' : mod_generics_cache .B .A ,
2856
- 'my_inner_a2' : mod_generics_cache .B . A ,
2856
+ 'my_inner_a2' : mod_generics_cache .A ,
2857
2857
'my_outer_a' : mod_generics_cache .A })
2858
2858
2859
2859
def test_respect_no_type_check (self ):
@@ -3641,7 +3641,7 @@ def test_annotation_usage(self):
3641
3641
self .assertEqual (tim .cool , 9000 )
3642
3642
self .assertEqual (CoolEmployee .__name__ , 'CoolEmployee' )
3643
3643
self .assertEqual (CoolEmployee ._fields , ('name' , 'cool' ))
3644
- self .assertEqual (CoolEmployee . __annotations__ ,
3644
+ self .assertEqual (gth ( CoolEmployee ) ,
3645
3645
collections .OrderedDict (name = str , cool = int ))
3646
3646
3647
3647
def test_annotation_usage_with_default (self ):
@@ -3655,7 +3655,7 @@ def test_annotation_usage_with_default(self):
3655
3655
3656
3656
self .assertEqual (CoolEmployeeWithDefault .__name__ , 'CoolEmployeeWithDefault' )
3657
3657
self .assertEqual (CoolEmployeeWithDefault ._fields , ('name' , 'cool' ))
3658
- self .assertEqual (CoolEmployeeWithDefault . __annotations__ ,
3658
+ self .assertEqual (gth ( CoolEmployeeWithDefault ) ,
3659
3659
dict (name = str , cool = int ))
3660
3660
self .assertEqual (CoolEmployeeWithDefault ._field_defaults , dict (cool = 0 ))
3661
3661
@@ -3823,7 +3823,7 @@ def test_typeddict_errors(self):
3823
3823
def test_py36_class_syntax_usage (self ):
3824
3824
self .assertEqual (LabelPoint2D .__name__ , 'LabelPoint2D' )
3825
3825
self .assertEqual (LabelPoint2D .__module__ , __name__ )
3826
- self .assertEqual (LabelPoint2D . __annotations__ , {'x' : int , 'y' : int , 'label' : str })
3826
+ self .assertEqual (gth ( LabelPoint2D ) , {'x' : int , 'y' : int , 'label' : str })
3827
3827
self .assertEqual (LabelPoint2D .__bases__ , (dict ,))
3828
3828
self .assertEqual (LabelPoint2D .__total__ , True )
3829
3829
self .assertNotIsSubclass (LabelPoint2D , typing .Sequence )
@@ -3882,19 +3882,19 @@ class Cat(Animal):
3882
3882
3883
3883
assert BaseAnimal .__required_keys__ == frozenset (['name' ])
3884
3884
assert BaseAnimal .__optional_keys__ == frozenset ([])
3885
- assert BaseAnimal . __annotations__ == {'name' : str }
3885
+ assert gth ( BaseAnimal ) == {'name' : str }
3886
3886
3887
3887
assert Animal .__required_keys__ == frozenset (['name' ])
3888
3888
assert Animal .__optional_keys__ == frozenset (['tail' , 'voice' ])
3889
- assert Animal . __annotations__ == {
3889
+ assert gth ( Animal ) == {
3890
3890
'name' : str ,
3891
3891
'tail' : bool ,
3892
3892
'voice' : str ,
3893
3893
}
3894
3894
3895
3895
assert Cat .__required_keys__ == frozenset (['name' , 'fur_color' ])
3896
3896
assert Cat .__optional_keys__ == frozenset (['tail' , 'voice' ])
3897
- assert Cat . __annotations__ == {
3897
+ assert gth ( Cat ) == {
3898
3898
'fur_color' : str ,
3899
3899
'name' : str ,
3900
3900
'tail' : bool ,
@@ -3915,23 +3915,23 @@ def test_io(self):
3915
3915
def stuff (a : IO ) -> AnyStr :
3916
3916
return a .readline ()
3917
3917
3918
- a = stuff . __annotations__ ['a' ]
3918
+ a = gth ( stuff ) ['a' ]
3919
3919
self .assertEqual (a .__parameters__ , (AnyStr ,))
3920
3920
3921
3921
def test_textio (self ):
3922
3922
3923
3923
def stuff (a : TextIO ) -> str :
3924
3924
return a .readline ()
3925
3925
3926
- a = stuff . __annotations__ ['a' ]
3926
+ a = gth ( stuff ) ['a' ]
3927
3927
self .assertEqual (a .__parameters__ , ())
3928
3928
3929
3929
def test_binaryio (self ):
3930
3930
3931
3931
def stuff (a : BinaryIO ) -> bytes :
3932
3932
return a .readline ()
3933
3933
3934
- a = stuff . __annotations__ ['a' ]
3934
+ a = gth ( stuff ) ['a' ]
3935
3935
self .assertEqual (a .__parameters__ , ())
3936
3936
3937
3937
def test_io_submodule (self ):
0 commit comments