From 7836a27ceba2395572f1b3b385c11e6a43910185 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Fri, 9 Oct 2015 00:03:51 -0400 Subject: [PATCH] Issue #25298: Add lock and rlock weakref tests (Contributed by Nir Soffer). --- Lib/test/lock_tests.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Lib/test/lock_tests.py b/Lib/test/lock_tests.py index afd6873683..055bf28565 100644 --- a/Lib/test/lock_tests.py +++ b/Lib/test/lock_tests.py @@ -7,6 +7,7 @@ import time from _thread import start_new_thread, TIMEOUT_MAX import threading import unittest +import weakref from test import support @@ -198,6 +199,17 @@ class BaseLockTests(BaseTestCase): self.assertFalse(results[0]) self.assertTimeout(results[1], 0.5) + def test_weakref_exists(self): + lock = self.locktype() + ref = weakref.ref(lock) + self.assertIsNotNone(ref()) + + def test_weakref_deleted(self): + lock = self.locktype() + ref = weakref.ref(lock) + del lock + self.assertIsNone(ref()) + class LockTests(BaseLockTests): """ -- 2.40.0