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

Method test_semaphore

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

Source from the content-addressed store, hash-verified

936 self.assertTrue(RGX_REPR.match(repr(sem)))
937
938 async def test_semaphore(self):
939 sem = asyncio.Semaphore()
940 self.assertEqual(1, sem._value)
941
942 with self.assertRaisesRegex(
943 TypeError,
944 "'Semaphore' object can't be awaited",
945 ):
946 await sem
947
948 self.assertFalse(sem.locked())
949 self.assertEqual(1, sem._value)
950
951 def test_semaphore_value(self):
952 self.assertRaises(ValueError, asyncio.Semaphore, -1)

Callers

nothing calls this directly

Calls 5

lockedMethod · 0.95
SemaphoreMethod · 0.80
assertRaisesRegexMethod · 0.80
assertFalseMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected