From 269a8226a953f94ea2eedacc9334ebb430f435ec Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Wed, 19 Jan 2022 18:32:25 +0300 Subject: [PATCH] bpo-46413: properly test `__{r}or__` code paths in `_SpecialGenericAlias` (GH-30640) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> (cherry picked from commit 0a49148e87cca11e3820cbff2abfd316986a68c6) Co-authored-by: Nikita Sobolev --- Lib/test/test_typing.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index f943aed73614cdf..8d0a09be6eda687 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -515,6 +515,10 @@ def test_ellipsis_in_generic(self): # 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 @@ -3834,6 +3838,10 @@ class B: ... 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):