Skip to content

Commit

Permalink
fix more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed Sep 28, 2024
1 parent 5f9e599 commit 9927b38
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions Lib/test/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,16 +723,10 @@ class B(metaclass=UnhashableMeta): ...

self.assertEqual((A | B).__args__, (A, B))
union1 = A | B
with self.assertRaises(TypeError):
hash(union1)

union2 = int | B
with self.assertRaises(TypeError):
hash(union2)

union3 = A | int
with self.assertRaises(TypeError):
hash(union3)

self.assertEqual(len({union1, union2, union3}), 3)

def test_instancecheck_and_subclasscheck(self):
for x in (int | str, typing.Union[int, str]):
Expand Down Expand Up @@ -1011,9 +1005,12 @@ def __eq__(self, other):
return 1 / 0

bt = BadType('bt', (), {})
bt2 = BadType('bt2', (), {})
# Comparison should fail and errors should propagate out for bad types.
union1 = int | bt
union2 = int | bt2
with self.assertRaises(ZeroDivisionError):
list[int] | list[bt]
union1 == union2

union_ga = (list[str] | int, collections.abc.Callable[..., str] | int,
d | int)
Expand Down

0 comments on commit 9927b38

Please sign in to comment.