MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_Hashable

Method test_Hashable

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 13

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

Tested by

no test coverage detected