diff options
Diffstat (limited to 'tests/basics/builtin_hash.py')
-rw-r--r-- | tests/basics/builtin_hash.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/basics/builtin_hash.py b/tests/basics/builtin_hash.py index d7615c3ec0..b6b2ad15cb 100644 --- a/tests/basics/builtin_hash.py +++ b/tests/basics/builtin_hash.py @@ -20,11 +20,12 @@ class A: print(hash(A())) print({A():1}) +# all user-classes have default __hash__ class B: pass hash(B()) - +# if __eq__ is defined then default __hash__ is not used class C: def __eq__(self, another): return True @@ -32,3 +33,12 @@ try: hash(C()) except TypeError: print("TypeError") + +# __hash__ must return an int +class D: + def __hash__(self): + return None +try: + hash(D()) +except TypeError: + print("TypeError") |