@@ -1941,6 +1941,10 @@ class SubSentinel(sentinel):
19411941 missing .__name__ = "CHANGED"
19421942 with self .assertRaises (AttributeError ):
19431943 missing .__module__ = "changed"
1944+ with self .assertRaises (AttributeError ):
1945+ del missing .__name__
1946+ with self .assertRaises (AttributeError ):
1947+ del missing .__module__
19441948
19451949 def test_sentinel_pickle (self ):
19461950 for proto in range (pickle .HIGHEST_PROTOCOL + 1 ):
@@ -1977,10 +1981,25 @@ class Name(str):
19771981 def test_sentinel_union (self ):
19781982 missing = sentinel ("MISSING" )
19791983
1984+ self .assertIsInstance (missing | int , typing .Union )
19801985 self .assertEqual ((missing | int ).__args__ , (missing , int ))
1986+ self .assertIsInstance (int | missing , typing .Union )
19811987 self .assertEqual ((int | missing ).__args__ , (int , missing ))
19821988 self .assertIs (missing | missing , missing )
19831989 self .assertEqual (repr (int | missing ), "int | MISSING" )
1990+ self .assertIsInstance (missing | None , typing .Union )
1991+ self .assertEqual ((missing | None ).__args__ , (missing , type (None )))
1992+ self .assertIsInstance (None | missing , typing .Union )
1993+ self .assertEqual ((None | missing ).__args__ , (type (None ), missing ))
1994+ self .assertIsInstance (missing | list [int ], typing .Union )
1995+ self .assertEqual ((missing | list [int ]).__args__ , (missing , list [int ]))
1996+ self .assertIsInstance (missing | (int | str ), typing .Union )
1997+ self .assertEqual ((missing | (int | str )).__args__ , (missing , int , str ))
1998+
1999+ with self .assertRaises (TypeError ):
2000+ missing | 1
2001+ with self .assertRaises (TypeError ):
2002+ 1 | missing
19842003
19852004 def test_round (self ):
19862005 self .assertEqual (round (0.0 ), 0.0 )
0 commit comments