Skip to content

Commit 8f33d77

Browse files
committed
Issue #25551: Test condition behavior instead of its internals
test_reset_internal_locks was looking at Event's _cond._lock. This makes it harder to change internals of the Condition object and makes the test fragile. The test was added by Nir Soffer in 6108d30dde21. Patch by Nir Soffer.
2 parents 488376e + d3f9c07 commit 8f33d77

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Lib/test/lock_tests.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,13 @@ def f():
407407
self.assertEqual(results, [True] * N)
408408

409409
def test_reset_internal_locks(self):
410+
# ensure that condition is still using a Lock after reset
410411
evt = self.eventtype()
411-
old_lock = evt._cond._lock
412+
with evt._cond:
413+
self.assertFalse(evt._cond.acquire(False))
412414
evt._reset_internal_locks()
413-
new_lock = evt._cond._lock
414-
self.assertIsNot(new_lock, old_lock)
415-
self.assertIs(type(new_lock), type(old_lock))
415+
with evt._cond:
416+
self.assertFalse(evt._cond.acquire(False))
416417

417418

418419
class ConditionTests(BaseTestCase):

0 commit comments

Comments
 (0)