Fix tests for Python 3.9

This commit is contained in:
Lumir Balhar 2020-05-28 13:33:38 +02:00
parent de04b10397
commit fa56b9fc3c
2 changed files with 48 additions and 1 deletions

44
fix_tests_for_py39.patch Normal file
View File

@ -0,0 +1,44 @@
From 501aa69ce62db361f1bc267105565ba6199d1f9b Mon Sep 17 00:00:00 2001
From: Lumir Balhar <lbalhar@redhat.com>
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)
"<class 'typing.Annotated'>"
but in Python 3.8 and lower:
>>> repr(Annotated)
"<class 'typing_extensions.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

View File

@ -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