docs/how-to-guides/module_scoped_loop_example.py
raw| 1 | import asyncio |
| 2 | |
| 3 | import pytest |
| 4 | |
| 5 | pytestmark = pytest.mark.asyncio(loop_scope="module") |
| 6 | |
| 7 | loop: asyncio.AbstractEventLoop |
| 8 | |
| 9 | |
| 10 | async def test_remember_loop(): |
| 11 | global loop |
| 12 | loop = asyncio.get_running_loop() |
| 13 | |
| 14 | |
| 15 | async def test_assert_same_loop(): |
| 16 | global loop |
| 17 | assert asyncio.get_running_loop() is loop |