From e512b4bf5dba8b5cdaff978e3f1bd76be698b440 Mon Sep 17 00:00:00 2001 From: Quentin Soubeyran Date: Wed, 15 Nov 2023 14:49:09 +0100 Subject: [PATCH] test: fix test incorrectly checking for hash collision avoidance --- tests/test_main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index d2857cec36..9f775fc65a 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -651,9 +651,11 @@ class TestModel(BaseModel): assert hash(m) == h # Keys can be missing, e.g. when using the deprecated copy method. - # This should change the hash, and more importantly hashing shouldn't raise a KeyError. + # This could change the hash, and more importantly hashing shouldn't raise a KeyError + # We don't assert here, because a hash collision is possible: the hash is not guaranteed to change + # However, hashing must not raise an exception, which simply calling hash() checks for del m.__dict__['a'] - assert h != hash(m) + hash(m) def test_default_hash_function_overrides_default_hash_function():