From 3f565df84d9462e503a8104f8725db207e33d631 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Thu, 5 Nov 2015 00:40:56 +0200 Subject: [PATCH] Issue #254074: Test condition behavior instead of internal defails. test_reset_internal_locks() was looking at Event's _cond._lock - this make it harder to change internal details of the Condition object and makes the test fragile. --- Lib/test/lock_tests.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Lib/test/lock_tests.py b/Lib/test/lock_tests.py index 055bf28..b5e3794 100644 --- a/Lib/test/lock_tests.py +++ b/Lib/test/lock_tests.py @@ -407,12 +407,13 @@ class EventTests(BaseTestCase): self.assertEqual(results, [True] * N) def test_reset_internal_locks(self): + # Ensure that condition is still using a Lock after reset evt = self.eventtype() - old_lock = evt._cond._lock + with evt._cond: + self.assertFalse(evt._cond.acquire(False)) evt._reset_internal_locks() - new_lock = evt._cond._lock - self.assertIsNot(new_lock, old_lock) - self.assertIs(type(new_lock), type(old_lock)) + with evt._cond: + self.assertFalse(evt._cond.acquire(False)) class ConditionTests(BaseTestCase): -- 2.4.3