]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46413: properly test `__{r}or__` code paths in `_SpecialGenericAlias` (GH-30640)
authorNikita Sobolev <mail@sobolevn.me>
Wed, 19 Jan 2022 15:32:25 +0000 (18:32 +0300)
committerGitHub <noreply@github.com>
Wed, 19 Jan 2022 15:32:25 +0000 (23:32 +0800)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Lib/test/test_typing.py

index e61f8828f5405ec38824199243d4dc69109a655f..8d024514fcb84776702868a664d31f5c5ae32fa7 100644 (file)
@@ -523,6 +523,10 @@ class BaseCallableTests:
         # Shouldn't crash; see https://github.com/python/typing/issues/259
         typing.List[Callable[..., str]]
 
+    def test_or_and_ror(self):
+        Callable = self.Callable
+        self.assertEqual(Callable | Tuple, Union[Callable, Tuple])
+        self.assertEqual(Tuple | Callable, Union[Tuple, Callable])
 
     def test_basic(self):
         Callable = self.Callable
@@ -3906,6 +3910,10 @@ class CollectionsAbcTests(BaseTestCase):
         A.register(B)
         self.assertIsSubclass(B, typing.Mapping)
 
+    def test_or_and_ror(self):
+        self.assertEqual(typing.Sized | typing.Awaitable, Union[typing.Sized, typing.Awaitable])
+        self.assertEqual(typing.Coroutine | typing.Hashable, Union[typing.Coroutine, typing.Hashable])
+
 
 class OtherABCTests(BaseTestCase):