8000 bpo-46413: properly test `__{r}or__` code paths in `_SpecialGenericAl… · miss-islington/cpython@6b390b7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6b390b7

Browse files
sobolevnmiss-islington
authored andcommitted
bpo-46413: properly test __{r}or__ code paths in _SpecialGenericAlias (pythonGH-30640)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> (cherry picked from commit 0a49148) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
1 parent 353674f commit 6b390b7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Lib/test/test_typing.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,10 @@ def test_ellipsis_in_generic(self):
494494
# Shouldn't crash; see https://github.com/python/typing/issues/259
495495
typing.List[Callable[..., str]]
496496

497+
def test_or_and_ror(self):
498+
Callable = self.Callable
499+
self.assertEqual(Callable | Tuple, Union[Callable, Tuple])
500+
self.assertEqual(Tuple | Callable, Union[Tuple, Callable])
497501

498502
class LiteralTests(BaseTestCase):
499503
def test_basics(self):
@@ -3629,6 +3633,10 @@ class B: ...
36293633
A.register(B)
36303634
self.assertIsSubclass(B, typing.Mapping)
36313635

3636+
def test_or_and_ror(self):
3637+
self.assertEqual(typing.Sized | typing.Awaitable, Union[typing.Sized, typing.Awaitable])
3638+
self.assertEqual(typing.Coroutine | typing.Hashable, Union[typing.Coroutine, typing.Hashable])
3639+
36323640

36333641
class OtherABCTests(BaseTestCase):
36343642

0 commit comments

Comments
 (0)
292E
0