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

This commit is contained in:
Raymond Hettinger 2015-10-09 00:03:51 -04:00
parent b3653a3458
commit 7836a27ceb
1 changed files with 12 additions and 0 deletions

View File

@ -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):
"""