[Python-checkins] cpython: Issue #25298: Add lock and rlock weakref tests (Contributed by Nir Soffer).

raymond.hettinger python-checkins at python.org
Fri Oct 9 00:03:57 EDT 2015


https://hg.python.org/cpython/rev/45903695e86c
changeset:   98612:45903695e86c
user:        Raymond Hettinger <python at rcn.com>
date:        Fri Oct 09 00:03:51 2015 -0400
summary:
  Issue #25298:  Add lock and rlock weakref tests (Contributed by Nir Soffer).

files:
  Lib/test/lock_tests.py |  12 ++++++++++++
  1 files changed, 12 insertions(+), 0 deletions(-)


diff --git a/Lib/test/lock_tests.py b/Lib/test/lock_tests.py
--- a/Lib/test/lock_tests.py
+++ b/Lib/test/lock_tests.py
@@ -7,6 +7,7 @@
 from _thread import start_new_thread, TIMEOUT_MAX
 import threading
 import unittest
+import weakref
 
 from test import support
 
@@ -198,6 +199,17 @@
         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):
     """

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list