Skip to content

Commit 4d5a7eb

Browse files
add a small test for hashability of bare classes
1 parent 2be5f3f commit 4d5a7eb

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
@@ -528,6 +528,16 @@ def update_persistent_hash(self, key_hash, key_builder):
528528
def test_class_hashing() -> None:
529529
keyb = KeyBuilder()
530530

531+
class WithoutUpdateMethod:
532+
pass
533+
534+
assert keyb(WithoutUpdateMethod) == keyb(WithoutUpdateMethod)
535+
assert keyb(WithoutUpdateMethod) == "da060d601d180d4c"
536+
537+
with pytest.raises(TypeError):
538+
# does not have update_persistent_hash() = > will raise
539+
keyb(WithoutUpdateMethod())
540+
531541
class WithUpdateMethod:
532542
def update_persistent_hash(self, key_hash, key_builder):
533543
# Only called for instances of this class, not for the class itself

0 commit comments

Comments
 (0)