Kaydet (Commit) 7836a27c authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Issue #25298: Add lock and rlock weakref tests (Contributed by Nir Soffer).

üst b3653a34
...@@ -7,6 +7,7 @@ import time ...@@ -7,6 +7,7 @@ import time
from _thread import start_new_thread, TIMEOUT_MAX from _thread import start_new_thread, TIMEOUT_MAX
import threading import threading
import unittest import unittest
import weakref
from test import support from test import support
...@@ -198,6 +199,17 @@ class BaseLockTests(BaseTestCase): ...@@ -198,6 +199,17 @@ class BaseLockTests(BaseTestCase):
self.assertFalse(results[0]) self.assertFalse(results[0])
self.assertTimeout(results[1], 0.5) 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): class LockTests(BaseLockTests):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment