Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7836a27

Browse files
committed
Issue #25298: Add lock and rlock weakref tests (Contributed by Nir Soffer).
1 parent b3653a3 commit 7836a27

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Lib/test/lock_tests.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from _thread import start_new_thread, TIMEOUT_MAX
88
import threading
99
import unittest
10+
import weakref
1011

1112
from test import support
1213

@@ -198,6 +199,17 @@ def f():
198199
self.assertFalse(results[0])
199200
self.assertTimeout(results[1], 0.5)
200201

202+
def test_weakref_exists(self):
203+
lock = self.locktype()
204+
ref = weakref.ref(lock)
205+
self.assertIsNotNone(ref())
206+
207+
def test_weakref_deleted(self):
208+
lock = self.locktype()
209+
ref = weakref.ref(lock)
210+
del lock
211+
self.assertIsNone(ref())
212+
201213

202214
class LockTests(BaseLockTests):
203215
"""

0 commit comments

Comments
 (0)