You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.4 KiB
45 lines
1.4 KiB
5 years ago
|
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
|
||
|
|