diff options
author | Anh71me <iyumelive@gmail.com> | 2022-10-07 18:23:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-07 18:23:06 (GMT) |
commit | d5fea01d9d439b1638cd8e5db19c33909841d86f (patch) | |
tree | 0be1fac1076f8ef77702a808ab4a1fa39a9814b7 /Lib/test/test_inspect.py | |
parent | 676d8ef3806758bcd1d3fd84a746c8a9b64480d0 (diff) | |
download | cpython-d5fea01d9d439b1638cd8e5db19c33909841d86f.zip cpython-d5fea01d9d439b1638cd8e5db19c33909841d86f.tar.gz cpython-d5fea01d9d439b1638cd8e5db19c33909841d86f.tar.bz2 |
GH-96073: Fix wild replacement in inspect.formatannotation (#96074)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r-- | Lib/test/test_inspect.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index 710b609..61fed32 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -1421,6 +1421,13 @@ class TestClassesAndFunctions(unittest.TestCase): self.assertEqual(inspect.get_annotations(isa.MyClassWithLocalAnnotations, eval_str=True), {'x': int}) +class TestFormatAnnotation(unittest.TestCase): + def test_typing_replacement(self): + from test.typinganndata.ann_module9 import ann, ann1 + self.assertEqual(inspect.formatannotation(ann), 'Union[List[str], int]') + self.assertEqual(inspect.formatannotation(ann1), 'Union[List[testModule.typing.A], int]') + + class TestIsDataDescriptor(unittest.TestCase): def test_custom_descriptors(self): |