Skip to content

Commit 4829f23

Browse files
changed test_legacy_union to test_typing_union. Changed behavior due to gh-105499
1 parent 2f9aa38 commit 4829f23

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

Lib/test/test_patma.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3457,17 +3457,14 @@ def test_class_or_union_not_specialform(self):
34573457
w = 0
34583458
self.assertIsNone(w)
34593459

3460-
def test_legacy_union_type(self):
3460+
def test_typing_union(self):
34613461
from typing import Union
3462-
IntOrStr = Union[int, str]
3463-
name = type(IntOrStr).__name__
3464-
msg = rf"called match pattern must be a class or typing.Union of classes \(got {name}\)"
3465-
w = None
3466-
with self.assertRaisesRegex(TypeError, msg):
3467-
match 1:
3468-
case IntOrStr():
3469-
w = 0
3470-
self.assertIsNone(w)
3462+
IntOrStr = Union[int, str] # identical to int | str since gh-105499
3463+
w = False
3464+
match 1:
3465+
case IntOrStr():
3466+
w = True
3467+
self.assertIs(w, True)
34713468

34723469
def test_expanded_union_mirrors_isinstance_success(self):
34733470
ListOfInt = list[int]

0 commit comments

Comments
 (0)