From 83fef48b2d540303479be6fa2f01f9fb0e47c06f Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Fri, 16 Oct 2020 08:35:42 +0200 Subject: [PATCH] Ensure objects live long enough in hash test --- tests/test_functional.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_functional.py b/tests/test_functional.py index f6a19697..3878d686 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -450,7 +450,13 @@ class TestFunctional(object): class C(object): pass - assert hash(C()) != hash(C()) + # Ensure both objects live long enough such that their ids/hashes + # can't be recycled. Thanks to Ask Hjorth Larsen for pointing that + # out. + c1 = C() + c2 = C() + + assert hash(c1) != hash(c2) def test_overwrite_base(self): """