MCPcopy Index your code
hub / github.com/python/cpython / test_with

Method test_with

Lib/test/lock_tests.py:188–215  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

186 self.assertEqual(len(bunch.finished), N)
187
188 def test_with(self):
189 lock = self.locktype()
190 def f():
191 lock.acquire()
192 lock.release()
193
194 def with_lock(err=None):
195 with lock:
196 if err is not None:
197 raise err
198
199 # Acquire the lock, do nothing, with releases the lock
200 with lock:
201 pass
202
203 # Check that the lock is unacquired
204 with Bunch(f, 1):
205 pass
206
207 # Acquire the lock, raise an exception, with releases the lock
208 with self.assertRaises(TypeError):
209 with lock:
210 raise TypeError
211
212 # Check that the lock is unacquired even if after an exception
213 # was raised in the previous "with lock:" block
214 with Bunch(f, 1):
215 pass
216
217 def test_thread_leak(self):
218 # The lock shouldn't leak a Thread instance when used from a foreign

Callers

nothing calls this directly

Calls 2

BunchClass · 0.70
assertRaisesMethod · 0.45

Tested by

no test coverage detected