@@ -1615,46 +1615,8 @@ def __call__(self, format, /, __Format=Format,
16151615 Annotate (), Format .FORWARDREF
16161616 )
16171617
1618- def test_non_function_annotate (self ):
1619- class Annotate :
1620- called_formats = []
1621-
1622- def __call__ (self , format = None , * , _self = None ):
1623- if _self is not None :
1624- self , format = _self , self
1625-
1626- self .called_formats .append (format )
1627- if format <= 2 : # VALUE or VALUE_WITH_FAKE_GLOBALS
1628- return {"x" : MyType }
1629- raise NotImplementedError
1630-
1631- @property
1632- def __defaults__ (self ):
1633- return (None ,)
1634-
1635- @property
1636- def __kwdefaults__ (self ):
1637- return {"_self" : self }
1638-
1639- @property
1640- def __code__ (self ):
1641- return self .__call__ .__code__
1642-
1643- annotate = Annotate ()
1644-
1645- with self .assertRaises (NameError ):
1646- annotationlib .call_annotate_function (annotate , Format .VALUE )
1647- self .assertEqual (annotate .called_formats [- 1 ], Format .VALUE )
1648-
1649- annotations = annotationlib .call_annotate_function (annotate , Format .STRING )
1650- self .assertEqual (annotations ["x" ], "MyType" )
1651- self .assertIn (Format .STRING , annotate .called_formats )
1652- self .assertEqual (annotate .called_formats [- 1 ], Format .VALUE_WITH_FAKE_GLOBALS )
1653-
1654- annotations = annotationlib .call_annotate_function (annotate , Format .FORWARDREF )
1655- self .assertEqual (annotations ["x" ], support .EqualToForwardRef ("MyType" ))
1656- self .assertIn (Format .FORWARDREF , annotate .called_formats )
1657- self .assertEqual (annotate .called_formats [- 1 ], Format .VALUE_WITH_FAKE_GLOBALS )
1618+ self .assertEqual (cm .exception .name , "__code__" )
1619+ self .assertIsInstance (cm .exception .obj , Annotate )
16581620
16591621 def test_full_non_function_annotate (self ):
16601622 def outer ():
0 commit comments