Issue #25298: Add lock and rlock weakref tests (Contributed by Nir Soffer).
This commit is contained in:
parent
b3653a3458
commit
7836a27ceb
|
@ -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):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue