mirror of
https://github.com/python/cpython
synced 2024-09-05 16:38:56 +00:00
bpo-44353: Add test to cover __or__ of two NewType (#27259)
This commit is contained in:
parent
965dd76e90
commit
4868b94c60
|
@ -3693,12 +3693,15 @@ class D(UserName):
|
||||||
|
|
||||||
def test_or(self):
|
def test_or(self):
|
||||||
UserId = NewType('UserId', int)
|
UserId = NewType('UserId', int)
|
||||||
|
UserName = NewType('UserName', str)
|
||||||
|
|
||||||
self.assertEqual(UserId | int, Union[UserId, int])
|
for cls in (int, UserName):
|
||||||
self.assertEqual(int | UserId, Union[int, UserId])
|
with self.subTest(cls=cls):
|
||||||
|
self.assertEqual(UserId | cls, Union[UserId, cls])
|
||||||
|
self.assertEqual(cls | UserId, Union[cls, UserId])
|
||||||
|
|
||||||
self.assertEqual(get_args(UserId | int), (UserId, int))
|
self.assertEqual(get_args(UserId | cls), (UserId, cls))
|
||||||
self.assertEqual(get_args(int | UserId), (int, UserId))
|
self.assertEqual(get_args(cls | UserId), (cls, UserId))
|
||||||
|
|
||||||
def test_special_attrs(self):
|
def test_special_attrs(self):
|
||||||
UserId = NewType('UserId', int)
|
UserId = NewType('UserId', int)
|
||||||
|
|
Loading…
Reference in a new issue