| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from textwrap import dedent |
| 4 |
|
| 5 |
from pytest import Pytester |
| 6 |
|
| 7 |
|
| 8 |
def test_asyncio_mark_provides_package_scoped_loop_strict_mode(pytester: Pytester): |
| 9 |
pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function") |
| 10 |
pytester.makepyfile( |
| 11 |
__init__="", |
| 12 |
conftest=dedent("""\ |
| 13 |
import pytest_asyncio |
| 14 |
@pytest_asyncio.fixture(loop_scope="module", scope="module") |
| 15 |
async def async_shared_module_fixture(): |
| 16 |
return True |
| 17 |
"""), |
| 18 |
test_module_one=dedent("""\ |
| 19 |
import pytest |
| 20 |
@pytest.mark.asyncio |
| 21 |
async def test_shared_module_fixture_use_a(async_shared_module_fixture): |
| 22 |
assert async_shared_module_fixture is True |
| 23 |
"""), |
| 24 |
test_module_two=dedent("""\ |
| 25 |
import pytest |
| 26 |
@pytest.mark.asyncio |
| 27 |
async def test_shared_module_fixture_use_b(async_shared_module_fixture): |
| 28 |
assert async_shared_module_fixture is True |
| 29 |
"""), |
| 30 |
) |
| 31 |
result = pytester.runpytest("--asyncio-mode=strict") |
| 32 |
result.assert_outcomes(passed=2) |