Skip to content

Commit 552a745

Browse files
committed
refactor: Set default asyncio event loop for fixtures in setup.cfg
1 parent fb5422f commit 552a745

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

docs/reference/markers/class_scoped_loop_with_fixture_strict_mode_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class TestClassScopedLoop:
1010
loop: asyncio.AbstractEventLoop
1111

12-
@pytest_asyncio.fixture(scope="class")
12+
@pytest_asyncio.fixture(loop_scope="class")
1313
async def my_fixture(self):
1414
TestClassScopedLoop.loop = asyncio.get_running_loop()
1515

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ python_files = test_*.py *_example.py
6767
addopts = -rsx --tb=short
6868
testpaths = docs tests
6969
asyncio_mode = auto
70+
asyncio_default_fixture_loop_scope = function
7071
junit_family=xunit2
7172
filterwarnings =
7273
error

tests/async_fixtures/test_async_fixtures_with_finalizer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import pytest
55

6+
import pytest_asyncio
7+
68

79
@pytest.mark.asyncio(loop_scope="module")
810
async def test_module_with_event_loop_finalizer(port_with_event_loop_finalizer):
@@ -25,7 +27,7 @@ def event_loop():
2527
loop.close()
2628

2729

28-
@pytest.fixture(scope="module")
30+
@pytest_asyncio.fixture(loop_scope="module", scope="module")
2931
async def port_with_event_loop_finalizer(request):
3032
def port_finalizer(finalizer):
3133
async def port_afinalizer():
@@ -40,7 +42,7 @@ async def port_afinalizer():
4042
return True
4143

4244

43-
@pytest.fixture(scope="module")
45+
@pytest_asyncio.fixture(loop_scope="module", scope="module")
4446
async def port_with_get_event_loop_finalizer(request):
4547
def port_finalizer(finalizer):
4648
async def port_afinalizer():

0 commit comments

Comments
 (0)