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

Method test_lock_by_with_statement

Lib/test/test_asyncio/test_locks.py:67–84  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

65 cls(loop=loop)
66
67 async def test_lock_by_with_statement(self):
68 primitives = [
69 asyncio.Lock(),
70 asyncio.Condition(),
71 asyncio.Semaphore(),
72 asyncio.BoundedSemaphore(),
73 ]
74
75 for lock in primitives:
76 await asyncio.sleep(0.01)
77 self.assertFalse(lock.locked())
78 with self.assertRaisesRegex(
79 TypeError,
80 r"'\w+' object can't be awaited"
81 ):
82 with await lock:
83 pass
84 self.assertFalse(lock.locked())
85
86 async def test_acquire(self):
87 lock = asyncio.Lock()

Callers

nothing calls this directly

Calls 8

LockMethod · 0.80
SemaphoreMethod · 0.80
BoundedSemaphoreMethod · 0.80
assertFalseMethod · 0.80
assertRaisesRegexMethod · 0.80
ConditionMethod · 0.45
sleepMethod · 0.45
lockedMethod · 0.45

Tested by

no test coverage detected