From fa56b9fc3c1376e48b2d0da8728661a9e7b2c507 Mon Sep 17 00:00:00 2001 From: Lumir Balhar Date: Thu, 28 May 2020 13:33:38 +0200 Subject: [PATCH] Fix tests for Python 3.9 --- fix_tests_for_py39.patch | 44 +++++++++++++++++++++++++++++++++++ python-typing-extensions.spec | 5 +++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 fix_tests_for_py39.patch diff --git a/fix_tests_for_py39.patch b/fix_tests_for_py39.patch new file mode 100644 index 0000000..af84867 --- /dev/null +++ b/fix_tests_for_py39.patch @@ -0,0 +1,44 @@ +From 501aa69ce62db361f1bc267105565ba6199d1f9b Mon Sep 17 00:00:00 2001 +From: Lumir Balhar +Date: Thu, 28 May 2020 13:24:02 +0200 +Subject: [PATCH] Use regex to allow `typing` or `typing_extensions` module + name + +This is useful for testing with Python 3.9 where: + +>>> repr(Annotated) +"" + +but in Python 3.8 and lower: + +>>> repr(Annotated) +"" +--- + typing_extensions/src_py3/test_typing_extensions.py | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/typing_extensions/src_py3/test_typing_extensions.py b/typing_extensions/src_py3/test_typing_extensions.py +index 04edac2..2858945 100644 +--- a/typing_extensions/src_py3/test_typing_extensions.py ++++ b/typing_extensions/src_py3/test_typing_extensions.py +@@ -1588,13 +1588,13 @@ class TypedDictTests(BaseTestCase): + class AnnotatedTests(BaseTestCase): + + def test_repr(self): +- self.assertEqual( ++ self.assertRegex( + repr(Annotated[int, 4, 5]), +- "typing_extensions.Annotated[int, 4, 5]" ++ r"typing(?:_extensions|)\.Annotated\[int, 4, 5\]" + ) +- self.assertEqual( ++ self.assertRegex( + repr(Annotated[List[int], 4, 5]), +- "typing_extensions.Annotated[typing.List[int], 4, 5]" ++ r"typing(?:_extensions|)\.Annotated\[typing\.List\[int\], 4, 5\]" + ) + + def test_flatten(self): +-- +2.26.2 + diff --git a/python-typing-extensions.spec b/python-typing-extensions.spec index 836a4a8..c677db7 100644 --- a/python-typing-extensions.spec +++ b/python-typing-extensions.spec @@ -9,6 +9,9 @@ License: Python URL: https://pypi.org/project/typing-extensions/ Source0: %{pypi_source} +# The same fix proposed upstream: https://github.com/python/typing/pull/729 +Patch0: fix_tests_for_py39.patch + BuildArch: noarch @@ -58,7 +61,7 @@ module from PyPi instead of using this one unless specifically writing code that must be compatible with multiple Python versions or requires experimental types. %prep -%autosetup -n %{srcname}-%{version} +%autosetup -n %{srcname}-%{version} -p2 %build %py3_build