()
| 15 | |
| 16 | |
| 17 | async def test_Event() -> None: |
| 18 | e = Event() |
| 19 | assert not e.is_set() |
| 20 | assert e.statistics().tasks_waiting == 0 |
| 21 | |
| 22 | with pytest.warns( |
| 23 | DeprecationWarning, |
| 24 | match=r"trio\.Event\.__bool__ is deprecated since Trio 0\.31\.0; use trio\.Event\.is_set instead \(https://github.com/python-trio/trio/issues/3238\)", |
| 25 | ): |
| 26 | e.__bool__() |
| 27 | |
| 28 | e.set() |
| 29 | assert e.is_set() |
| 30 | with assert_checkpoints(): |
| 31 | await e.wait() |
| 32 | |
| 33 | e = Event() |
| 34 | |
| 35 | record = [] |
| 36 | |
| 37 | async def child() -> None: |
| 38 | record.append("sleeping") |
| 39 | await e.wait() |
| 40 | record.append("woken") |
| 41 | |
| 42 | async with _core.open_nursery() as nursery: |
| 43 | nursery.start_soon(child) |
| 44 | nursery.start_soon(child) |
| 45 | await wait_all_tasks_blocked() |
| 46 | assert record == ["sleeping", "sleeping"] |
| 47 | assert e.statistics().tasks_waiting == 2 |
| 48 | e.set() |
| 49 | await wait_all_tasks_blocked() |
| 50 | assert record == ["sleeping", "sleeping", "woken", "woken"] |
| 51 | |
| 52 | |
| 53 | async def test_CapacityLimiter() -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…