summaryrefslogtreecommitdiffstats
path: root/Lib/test/lock_tests.py
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-04-29 14:25:51 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2016-04-29 14:25:51 (GMT)
commitdd745cc3ff853fd5b641c035a860f0ac84f2b401 (patch)
tree62b672ca0fccdc99cf59370bc1468c768a7adaee /Lib/test/lock_tests.py
parent0ac70c0e9052db0c8ca6da517019c9c8f3f5d30d (diff)
parent6d34bbbfc7ac1a5a8d518ed1b767239de26650c5 (diff)
downloadcpython-dd745cc3ff853fd5b641c035a860f0ac84f2b401.zip
cpython-dd745cc3ff853fd5b641c035a860f0ac84f2b401.tar.gz
cpython-dd745cc3ff853fd5b641c035a860f0ac84f2b401.tar.bz2
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.
Diffstat (limited to 'Lib/test/lock_tests.py')
-rw-r--r--Lib/test/lock_tests.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/test/lock_tests.py b/Lib/test/lock_tests.py
index 055bf28..a6cb3b1 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):