File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -3309,6 +3309,25 @@ def test_mapping_pattern_duplicate_key_edge_case3(self):
33093309
33103310class TestTypeErrors (unittest .TestCase ):
33113311
3312+ def test_generic_type (self ):
3313+ t = list [str ]
3314+ w = None
3315+ with self .assertRaises (TypeError ):
3316+ match ["s" ]:
3317+ case t ():
3318+ w = 0
3319+ self .assertIsNone (w )
3320+
3321+ def test_legacy_generic_type (self ):
3322+ from typing import List
3323+ t = List [str ]
3324+ w = None
3325+ with self .assertRaises (TypeError ):
3326+ match ["s" ]:
3327+ case t ():
3328+ w = 0
3329+ self .assertIsNone (w )
3330+
33123331 def test_accepts_positional_subpatterns_0 (self ):
33133332 class Class :
33143333 __match_args__ = ()
@@ -3441,6 +3460,16 @@ def test_patma_legacy_union_type(self):
34413460 w = 0
34423461 self .assertIsNone (w )
34433462
3463+ def test_generic_union_type (self ):
3464+ from typing import List
3465+ t = list [str ] | List [str ]
3466+ w = None
3467+ with self .assertRaises (TypeError ):
3468+ match ["s" ]:
3469+ case t ():
3470+ w = 0
3471+ self .assertIsNone (w )
3472+
34443473 def test_regular_protocol (self ):
34453474 from typing import Protocol
34463475 class P (Protocol ): ...
You can’t perform that action at this time.
0 commit comments