docs/reference/markers/class_scoped_loop_strict_mode_example.py
raw| 1 | import asyncio |
| 2 | |
| 3 | import pytest |
| 4 | |
| 5 | |
| 6 | @pytest.mark.asyncio(loop_scope="class") |
| 7 | class TestClassScopedLoop: |
| 8 | loop: asyncio.AbstractEventLoop |
| 9 | |
| 10 | async def test_remember_loop(self): |
| 11 | TestClassScopedLoop.loop = asyncio.get_running_loop() |
| 12 | |
| 13 | async def test_this_runs_in_same_loop(self): |
| 14 | assert asyncio.get_running_loop() is TestClassScopedLoop.loop |