File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -1786,6 +1786,33 @@ def test_forwardref(self):
17861786 fwdref = ForwardRef ('fwdref' )
17871787 self .assertEqual (inspect .formatannotation (fwdref ), 'fwdref' )
17881788
1789+ def test_formatannotationrelativeto (self ):
1790+ import typing
1791+ from test .typinganndata .ann_module9 import A
1792+
1793+ class B : ...
1794+
1795+ self .assertEqual (
1796+ inspect .formatannotationrelativeto (None )(A ),
1797+ 'testModule.typing.A' ,
1798+ )
1799+ self .assertEqual (
1800+ inspect .formatannotationrelativeto (inspect )(A ),
1801+ 'testModule.typing.A' ,
1802+ )
1803+ self .assertEqual (
1804+ inspect .formatannotationrelativeto (typing .Literal )(A ),
1805+ 'testModule.typing.A' ,
1806+ )
1807+ self .assertEqual (
1808+ inspect .formatannotationrelativeto (B )(A ),
1809+ 'testModule.typing.A' ,
1810+ )
1811+ self .assertEqual (
1812+ inspect .formatannotationrelativeto (A )(A ),
1813+ 'A' ,
1814+ )
1815+
17891816
17901817class TestIsMethodDescriptor (unittest .TestCase ):
17911818
You can’t perform that action at this time.
0 commit comments