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

Method test_Hashable

Lib/test/test_collections.py:909–933  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

907 self.assertNotIsSubclass(CoroLike, Coroutine)
908
909 def test_Hashable(self):
910 # Check some non-hashables
911 non_samples = [bytearray(), list(), set(), dict()]
912 for x in non_samples:
913 self.assertNotIsInstance(x, Hashable)
914 self.assertNotIsSubclass(type(x), Hashable)
915 # Check some hashables
916 samples = [None,
917 int(), float(), complex(),
918 str(),
919 tuple(), frozenset(),
920 int, list, object, type, bytes()
921 ]
922 for x in samples:
923 self.assertIsInstance(x, Hashable)
924 self.assertIsSubclass(type(x), Hashable)
925 self.assertRaises(TypeError, Hashable)
926 # Check direct subclassing
927 class H(Hashable):
928 def __hash__(self):
929 return super().__hash__()
930 self.assertEqual(hash(H()), 0)
931 self.assertNotIsSubclass(int, H)
932 self.validate_abstract_methods(Hashable, '__hash__')
933 self.validate_isinstance(Hashable, '__hash__')
934
935 def test_AsyncIterable(self):
936 class AI:

Callers

nothing calls this directly

Calls 12

listClass · 0.85
setFunction · 0.85
strFunction · 0.85
assertNotIsInstanceMethod · 0.80
assertNotIsSubclassMethod · 0.80
assertIsInstanceMethod · 0.80
assertIsSubclassMethod · 0.80
validate_isinstanceMethod · 0.80
HClass · 0.70
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected