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 @@ -3318,6 +3318,25 @@ def test_mapping_pattern_duplicate_key_edge_case3(self):
33183318
33193319class TestTypeErrors (unittest .TestCase ):
33203320
3321+ def test_generic_type (self ):
3322+ t = list [str ]
3323+ w = None
3324+ with self .assertRaises (TypeError ):
3325+ match ["s" ]:
3326+ case t ():
3327+ w = 0
3328+ self .assertIsNone (w )
3329+
3330+ def test_legacy_generic_type (self ):
3331+ from typing import List
3332+ t = List [str ]
3333+ w = None
3334+ with self .assertRaises (TypeError ):
3335+ match ["s" ]:
3336+ case t ():
3337+ w = 0
3338+ self .assertIsNone (w )
3339+
33213340 def test_accepts_positional_subpatterns_0 (self ):
33223341 class Class :
33233342 __match_args__ = ()
@@ -3450,6 +3469,16 @@ def test_patma_legacy_union_type(self):
34503469 w = 0
34513470 self .assertIsNone (w )
34523471
3472+ def test_generic_union_type (self ):
3473+ from typing import List
3474+ t = list [str ] | List [str ]
3475+ w = None
3476+ with self .assertRaises (TypeError ):
3477+ match ["s" ]:
3478+ case t ():
3479+ w = 0
3480+ self .assertIsNone (w )
3481+
34533482 def test_regular_protocol (self ):
34543483 from typing import Protocol
34553484 class P (Protocol ): ...
You can’t perform that action at this time.
0 commit comments