MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_with

Method test_with

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

Source from the content-addressed store, hash-verified

182 self.assertEqual(len(bunch.finished), N)
183
184 def test_with(self):
185 lock = self.locktype()
186 def f():
187 lock.acquire()
188 lock.release()
189
190 def with_lock(err=None):
191 with lock:
192 if err is not None:
193 raise err
194
195 # Acquire the lock, do nothing, with releases the lock
196 with lock:
197 pass
198
199 # Check that the lock is unacquired
200 with Bunch(f, 1):
201 pass
202
203 # Acquire the lock, raise an exception, with releases the lock
204 with self.assertRaises(TypeError):
205 with lock:
206 raise TypeError
207
208 # Check that the lock is unacquired even if after an exception
209 # was raised in the previous "with lock:" block
210 with Bunch(f, 1):
211 pass
212
213 @unittest.skip("TODO: RUSTPYTHON; sometimes hangs")
214 def test_thread_leak(self):

Callers

nothing calls this directly

Calls 2

BunchClass · 0.70
assertRaisesMethod · 0.45

Tested by

no test coverage detected