Skip to content

Commit 7bab32e

Browse files
committed
tests: Add further tests for class defining __hash__.
1 parent c50772d commit 7bab32e

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

tests/basics/builtin_hash.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,15 @@ def __hash__(self):
4242
hash(D())
4343
except TypeError:
4444
print("TypeError")
45+
46+
# __hash__ returning a bool should be converted to an int
47+
class E:
48+
def __hash__(self):
49+
return True
50+
print(hash(E()))
51+
52+
# __hash__ returning a large number should be truncated
53+
class F:
54+
def __hash__(self):
55+
return 1 << 70 | 1
56+
print(hash(F()) != 0)

0 commit comments

Comments
 (0)