@@ -253,10 +253,11 @@ def test_union_any(self):
253253 def test_union_object (self ):
254254 u = Union [object ]
255255 self .assertEqual (u , object )
256- u = Union [int , object ]
257- self .assertEqual (u , object )
258- u = Union [object , int ]
259- self .assertEqual (u , object )
256+ u1 = Union [int , object ]
257+ u2 = Union [object , int ]
258+ self .assertEqual (u1 , u2 )
259+ self .assertNotEqual (u1 , object )
260+ self .assertNotEqual (u2 , object )
260261
261262 def test_unordered (self ):
262263 u1 = Union [int , float ]
@@ -267,13 +268,11 @@ def test_single_class_disappears(self):
267268 t = Union [Employee ]
268269 self .assertIs (t , Employee )
269270
270- def test_base_class_disappears (self ):
271- u = Union [Employee , Manager , int ]
272- self .assertEqual (u , Union [int , Employee ])
273- u = Union [Manager , int , Employee ]
274- self .assertEqual (u , Union [int , Employee ])
271+ def test_base_class_kept (self ):
275272 u = Union [Employee , Manager ]
276- self .assertIs (u , Employee )
273+ self .assertNotEqual (u , Employee )
274+ self .assertIn (Employee , u .__args__ )
275+ self .assertIn (Manager , u .__args__ )
277276
278277 def test_union_union (self ):
279278 u = Union [int , float ]
@@ -317,7 +316,8 @@ def test_cannot_instantiate(self):
317316 def test_union_generalization (self ):
318317 self .assertFalse (Union [str , typing .Iterable [int ]] == str )
319318 self .assertFalse (Union [str , typing .Iterable [int ]] == typing .Iterable [int ])
320- self .assertTrue (Union [str , typing .Iterable ] == typing .Iterable )
319+ self .assertIn (str , Union [str , typing .Iterable [int ]].__args__ )
320+ self .assertIn (typing .Iterable [int ], Union [str , typing .Iterable [int ]].__args__ )
321321
322322 def test_union_compare_other (self ):
323323 self .assertNotEqual (Union , object )
@@ -917,7 +917,7 @@ def test_extended_generic_rules_eq(self):
917917 self .assertEqual (Union [T , U ][int , Union [int , str ]], Union [int , str ])
918918 class Base : ...
919919 class Derived (Base ): ...
920- self .assertEqual (Union [T , Base ][Derived ], Base )
920+ self .assertEqual (Union [T , Base ][Union [ Base , Derived ]], Union [ Base , Derived ] )
921921 with self .assertRaises (TypeError ):
922922 Union [T , int ][1 ]
923923
0 commit comments