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

Method testHash

Lib/test/test_fractions.py:1147–1156  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1145 self.assertEqual("7", str(F(7, 1)))
1146
1147 def testHash(self):
1148 hmod = sys.hash_info.modulus
1149 hinf = sys.hash_info.inf
1150 self.assertEqual(hash(2.5), hash(F(5, 2)))
1151 self.assertEqual(hash(10**50), hash(F(10**50)))
1152 self.assertNotEqual(hash(float(10**23)), hash(F(10**23)))
1153 self.assertEqual(hinf, hash(F(1, hmod)))
1154 # Check that __hash__ produces the same value as hash(), for
1155 # consistency with int and Decimal. (See issue #10356.)
1156 self.assertEqual(hash(F(-1)), F(-1).__hash__())
1157
1158 def testApproximatePi(self):
1159 # Algorithm borrowed from

Callers

nothing calls this directly

Calls 4

assertNotEqualMethod · 0.80
FClass · 0.70
assertEqualMethod · 0.45
__hash__Method · 0.45

Tested by

no test coverage detected