(self)
| 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 |
nothing calls this directly
no test coverage detected