Skip to content

Commit 26328fb

Browse files
add a small test for hashability of bare classes
1 parent e1fa6e0 commit 26328fb

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

pytools/test/test_persistent_dict.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,16 @@ def update_persistent_hash(self, key_hash, key_builder):
567567
def test_class_hashing() -> None:
568568
keyb = KeyBuilder()
569569

570+
class WithoutUpdateMethod:
571+
pass
572+
573+
assert keyb(WithoutUpdateMethod) == keyb(WithoutUpdateMethod)
574+
assert keyb(WithoutUpdateMethod) == "da060d601d180d4c"
575+
576+
with pytest.raises(TypeError):
577+
# does not have update_persistent_hash() = > will raise
578+
keyb(WithoutUpdateMethod())
579+
570580
class WithUpdateMethod:
571581
def update_persistent_hash(self, key_hash, key_builder):
572582
# Only called for instances of this class, not for the class itself

0 commit comments

Comments
 (0)