@@ -531,6 +531,14 @@ def test_pickle(self):
531531 pickled = pickle .dumps (self .bottom_type , protocol = proto )
532532 self .assertIs (self .bottom_type , pickle .loads (pickled ))
533533
534+ @skipUnless (TYPING_3_10_0 , "PEP 604 has yet to be" )
535+ def test_or (self ):
536+ self .assertEqual (self .bottom_type | int , Union [self .bottom_type , int ])
537+ self .assertEqual (int | self .bottom_type , Union [int , self .bottom_type ])
538+
539+ self .assertEqual (get_args (self .bottom_type | int ), (self .bottom_type , int ))
540+ self .assertEqual (get_args (int | self .bottom_type ), (int , self .bottom_type ))
541+
534542
535543class NoReturnTests (BottomTypeTestsMixin , BaseTestCase ):
536544 bottom_type = NoReturn
@@ -5332,6 +5340,17 @@ class A(TypedDict):
53325340 def test_dunder_dict (self ):
53335341 self .assertIsInstance (TypedDict .__dict__ , dict )
53345342
5343+ @skipUnless (TYPING_3_10_0 , "PEP 604 has yet to be" )
5344+ def test_or (self ):
5345+ class TD (TypedDict ):
5346+ a : int
5347+
5348+ self .assertEqual (TD | int , Union [TD , int ])
5349+ self .assertEqual (int | TD , Union [int , TD ])
5350+
5351+ self .assertEqual (get_args (TD | int ), (TD , int ))
5352+ self .assertEqual (get_args (int | TD ), (int , TD ))
5353+
53355354class AnnotatedTests (BaseTestCase ):
53365355
53375356 def test_repr (self ):
@@ -6394,6 +6413,14 @@ def test_pickle(self):
63946413 pickled = pickle .dumps (LiteralString , protocol = proto )
63956414 self .assertIs (LiteralString , pickle .loads (pickled ))
63966415
6416+ @skipUnless (TYPING_3_10_0 , "PEP 604 has yet to be" )
6417+ def test_or (self ):
6418+ self .assertEqual (LiteralString | int , Union [LiteralString , int ])
6419+ self .assertEqual (int | LiteralString , Union [int , LiteralString ])
6420+
6421+ self .assertEqual (get_args (LiteralString | int ), (LiteralString , int ))
6422+ self .assertEqual (get_args (int | LiteralString ), (int , LiteralString ))
6423+
63976424
63986425class SelfTests (BaseTestCase ):
63996426 def test_basics (self ):
0 commit comments