(self)
| 1220 | self.assertRaises(ValueError, hasattr, B(), "b") |
| 1221 | |
| 1222 | def test_hash(self): |
| 1223 | hash(None) |
| 1224 | self.assertEqual(hash(1), hash(1)) |
| 1225 | self.assertEqual(hash(1), hash(1.0)) |
| 1226 | hash('spam') |
| 1227 | self.assertEqual(hash('spam'), hash(b'spam')) |
| 1228 | hash((0,1,2,3)) |
| 1229 | def f(): pass |
| 1230 | hash(f) |
| 1231 | self.assertRaises(TypeError, hash, []) |
| 1232 | self.assertRaises(TypeError, hash, {}) |
| 1233 | # Bug 1536021: Allow hash to return long objects |
| 1234 | class X: |
| 1235 | def __hash__(self): |
| 1236 | return 2**100 |
| 1237 | self.assertEqual(type(hash(X())), int) |
| 1238 | class Z(int): |
| 1239 | def __hash__(self): |
| 1240 | return self |
| 1241 | self.assertEqual(hash(Z(42)), hash(42)) |
| 1242 | |
| 1243 | def test_invalid_hash_typeerror(self): |
| 1244 | # GH-140406: The returned object from __hash__() would leak if it |
nothing calls this directly
no test coverage detected