mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
bpo-46529: increase coverage of typing.Union.__repr__ method (GH-30911)
(cherry picked from commit d0c690b5f8)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
f8a805bde1
commit
29eefcc9c6
1 changed files with 9 additions and 0 deletions
|
|
@ -304,6 +304,15 @@ class UnionTests(BaseTestCase):
|
|||
u = Union[list[int], dict[str, float]]
|
||||
self.assertEqual(repr(u), 'typing.Union[list[int], dict[str, float]]')
|
||||
|
||||
u = Union[None, str]
|
||||
self.assertEqual(repr(u), 'typing.Optional[str]')
|
||||
u = Union[str, None]
|
||||
self.assertEqual(repr(u), 'typing.Optional[str]')
|
||||
u = Union[None, str, int]
|
||||
self.assertEqual(repr(u), 'typing.Union[NoneType, str, int]')
|
||||
u = Optional[str]
|
||||
self.assertEqual(repr(u), 'typing.Optional[str]')
|
||||
|
||||
def test_cannot_subclass(self):
|
||||
with self.assertRaises(TypeError):
|
||||
class C(Union):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue