From: Berker Peksag Date: Fri, 29 Apr 2016 14:25:29 +0000 (+0300) Subject: Issue #25551: Test condition behavior instead of its internals X-Git-Tag: v3.6.0a1~95^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6d34bbbfc7ac1a5a8d518ed1b767239de26650c5;p=thirdparty%2FPython%2Fcpython.git 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. --- diff --git a/Lib/test/lock_tests.py b/Lib/test/lock_tests.py index afd687368324..a64aa18cd3aa 100644 --- a/Lib/test/lock_tests.py +++ b/Lib/test/lock_tests.py @@ -395,12 +395,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):