@@ -3469,7 +3469,51 @@ def test_patma_legacy_union_type(self):
34693469 w = 0
34703470 self .assertIsNone (w )
34713471
3472- def test_union_mirrors_isinstance_success (self ):
3472+ def test_expanded_union_mirrors_isinstance_success (self ):
3473+ ListOfInt = list [int ]
3474+ t = int | ListOfInt
3475+ try : # get the isinstance result
3476+ reference = isinstance (1 , t )
3477+ except TypeError as exc :
3478+ reference = exc
3479+
3480+ try : # get the match-case result
3481+ match 1 :
3482+ case int () | ListOfInt ():
3483+ result = True
3484+ case _:
3485+ result = False
3486+ except TypeError as exc :
3487+ result = exc
3488+
3489+ # we should ge the same result
3490+ self .assertIs (result , True )
3491+ self .assertIs (reference , True )
3492+
3493+ def test_expanded_union_mirrors_isinstance_failure (self ):
3494+ ListOfInt = list [int ]
3495+ t = ListOfInt | int
3496+
3497+ try : # get the isinstance result
3498+ reference = isinstance (1 , t )
3499+ except TypeError as exc :
3500+ reference = exc
3501+
3502+ try : # get the match-case result
3503+ match 1 :
3504+ case ListOfInt () | int ():
3505+ result = True
3506+ case _:
3507+ result = False
3508+ except TypeError as exc :
3509+ result = exc
3510+
3511+ # we should ge the same result
3512+ self .assertIsInstance (result , TypeError )
3513+ self .assertIsInstance (reference , TypeError )
3514+
3515+
3516+ def test_union_type_mirrors_isinstance_success (self ):
34733517 t = int | list [int ]
34743518
34753519 try : # get the isinstance result
@@ -3490,7 +3534,7 @@ def test_union_mirrors_isinstance_success(self):
34903534 self .assertIs (result , True )
34913535 self .assertIs (reference , True )
34923536
3493- def test_union_mirrors_isinstance_failure (self ):
3537+ def test_union_type_mirrors_isinstance_failure (self ):
34943538 t = list [int ] | int
34953539
34963540 try : # get the isinstance result
0 commit comments