From 8c78fa7300211703dd90bccad8f89c5610d69576 Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Mon, 8 Jun 2020 20:18:47 +0300 Subject: [PATCH] Make tests for Annotated work with Python 3.9 (#731) Python 3.9+ has its own version of Annotated. Make the tests take it into account similarly to how this is done for other backported typing constructs. --- typing_extensions/src_py3/test_typing_extensions.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/typing_extensions/src_py3/test_typing_extensions.py b/typing_extensions/src_py3/test_typing_extensions.py index 04edac27a..dcac6e63a 100644 --- a/typing_extensions/src_py3/test_typing_extensions.py +++ b/typing_extensions/src_py3/test_typing_extensions.py @@ -1588,13 +1588,17 @@ def test_keys_inheritance(self): class AnnotatedTests(BaseTestCase): def test_repr(self): + if hasattr(typing, 'Annotated'): + mod_name = 'typing' + else: + mod_name = "typing_extensions" self.assertEqual( repr(Annotated[int, 4, 5]), - "typing_extensions.Annotated[int, 4, 5]" + mod_name + ".Annotated[int, 4, 5]" ) self.assertEqual( repr(Annotated[List[int], 4, 5]), - "typing_extensions.Annotated[typing.List[int], 4, 5]" + mod_name + ".Annotated[typing.List[int], 4, 5]" ) def test_flatten(self):