summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-07-20 16:06:38 (GMT)
committerGitHub <noreply@github.com>2021-07-20 16:06:38 (GMT)
commit9ae5ba7dbf08d56a1b30d67fcde75532fe136d77 (patch)
treeb9eb947071aa13799f5b7020911e4e0064fe22c1 /Lib
parentc2f33dfc83ab270412bf243fb21f724037effa1a (diff)
downloadcpython-9ae5ba7dbf08d56a1b30d67fcde75532fe136d77.zip
cpython-9ae5ba7dbf08d56a1b30d67fcde75532fe136d77.tar.gz
cpython-9ae5ba7dbf08d56a1b30d67fcde75532fe136d77.tar.bz2
bpo-44353: Add test to cover __or__ of two NewType (GH-27259) (#27261)
(cherry picked from commit 4868b94c6089d457673b1ba5b5b64c2f38c435af) Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_typing.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index 3a28be1..f5abbb2 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -3692,12 +3692,15 @@ class NewTypeTests(BaseTestCase):
def test_or(self):
UserId = NewType('UserId', int)
+ UserName = NewType('UserName', str)
- self.assertEqual(UserId | int, Union[UserId, int])
- self.assertEqual(int | UserId, Union[int, UserId])
+ for cls in (int, UserName):
+ 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(int | UserId), (int, UserId))
+ self.assertEqual(get_args(UserId | cls), (UserId, cls))
+ self.assertEqual(get_args(cls | UserId), (cls, UserId))
def test_special_attrs(self):
UserId = NewType('UserId', int)