MCPcopy Index your code
hub / github.com/python/cpython / test_hash_eq

Method test_hash_eq

Lib/test/test_typing.py:9684–9702  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

9682 L[int, float]
9683
9684 def test_hash_eq(self):
9685 self.assertEqual(len({Annotated[int, 4, 5], Annotated[int, 4, 5]}), 1)
9686 self.assertNotEqual(Annotated[int, 4, 5], Annotated[int, 5, 4])
9687 self.assertNotEqual(Annotated[int, 4, 5], Annotated[str, 4, 5])
9688 self.assertNotEqual(Annotated[int, 4], Annotated[int, 4, 4])
9689 self.assertEqual(
9690 {Annotated[int, 4, 5], Annotated[int, 4, 5], Annotated[T, 4, 5]},
9691 {Annotated[int, 4, 5], Annotated[T, 4, 5]}
9692 )
9693 # Unhashable `metadata` raises `TypeError`:
9694 a1 = Annotated[int, []]
9695 with self.assertRaises(TypeError):
9696 hash(a1)
9697
9698 class A:
9699 __hash__ = None
9700 a2 = Annotated[int, A()]
9701 with self.assertRaises(TypeError):
9702 hash(a2)
9703
9704 def test_instantiate(self):
9705 class C:

Callers

nothing calls this directly

Calls 4

assertNotEqualMethod · 0.80
AClass · 0.70
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected