diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/basics/builtin_hash.py | 12 | ||||
-rw-r--r-- | tests/cmdline/cmd_showbc.py.exp | 2 |
2 files changed, 12 insertions, 2 deletions
diff --git a/tests/basics/builtin_hash.py b/tests/basics/builtin_hash.py index d7615c3ec..b6b2ad15c 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") diff --git a/tests/cmdline/cmd_showbc.py.exp b/tests/cmdline/cmd_showbc.py.exp index 02e367654..6231d3fe9 100644 --- a/tests/cmdline/cmd_showbc.py.exp +++ b/tests/cmdline/cmd_showbc.py.exp @@ -83,7 +83,7 @@ arg names: 59 BINARY_OP 5 __add__ 60 STORE_FAST 8 61 LOAD_FAST 0 -62 UNARY_OP 3 +62 UNARY_OP 4 63 STORE_FAST 9 64 LOAD_FAST 0 65 UNARY_OP 0 |