docs/how-to-guides/change_fixture_loop_example.py
raw| 1 | import asyncio |
| 2 | |
| 3 | import pytest |
| 4 | |
| 5 | import pytest_asyncio |
| 6 | |
| 7 | |
| 8 | @pytest_asyncio.fixture(loop_scope="module") |
| 9 | async def current_loop(): |
| 10 | return asyncio.get_running_loop() |
| 11 | |
| 12 | |
| 13 | @pytest.mark.asyncio(loop_scope="module") |
| 14 | async def test_runs_in_module_loop(current_loop): |
| 15 | assert current_loop is asyncio.get_running_loop() |