diff options
author | Raymond Hettinger <python@rcn.com> | 2015-10-09 00:03:51 -0400 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-10-09 00:03:51 -0400 |
commit | 7836a27ceba2395572f1b3b385c11e6a43910185 (patch) | |
tree | 932579f855fe9b48b6283df8967224d2d048120b /Lib/test/lock_tests.py | |
parent | b3653a34580684d210daed5cbb8a676c4d7a33fd (diff) | |
download | cpython-git-7836a27ceba2395572f1b3b385c11e6a43910185.tar.gz |
Issue #25298: Add lock and rlock weakref tests (Contributed by Nir Soffer).
Diffstat (limited to 'Lib/test/lock_tests.py')
-rw-r--r-- | 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 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): """ |