Skip to content

Commit b6deb15

Browse files
committed
fix: Remove pytest_generate_tests.
This also fixes an issue that could cause the warning for the deprecated *scope* argument to the asyncio marker to be reported multiple times.
1 parent d1c68f8 commit b6deb15

File tree

3 files changed

+2
-28
lines changed

3 files changed

+2
-28
lines changed

changelog.d/+b22c903a.fixed.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
An error that could cause duplicate warnings to be issued

pytest_asyncio/plugin.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
Function,
4343
Item,
4444
Mark,
45-
Metafunc,
4645
MonkeyPatch,
4746
Parser,
4847
PytestCollectionWarning,
@@ -547,32 +546,6 @@ def _temporary_event_loop_policy(policy: AbstractEventLoopPolicy) -> Iterator[No
547546
_set_event_loop(old_loop)
548547

549548

550-
@pytest.hookimpl(tryfirst=True)
551-
def pytest_generate_tests(metafunc: Metafunc) -> None:
552-
marker = metafunc.definition.get_closest_marker("asyncio")
553-
if not marker:
554-
return
555-
default_loop_scope = _get_default_test_loop_scope(metafunc.config)
556-
loop_scope = _get_marked_loop_scope(marker, default_loop_scope)
557-
runner_fixture_id = f"_{loop_scope}_scoped_runner"
558-
# This specific fixture name may already be in metafunc.argnames, if this
559-
# test indirectly depends on the fixture. For example, this is the case
560-
# when the test depends on an async fixture, both of which share the same
561-
# event loop fixture mark.
562-
if runner_fixture_id in metafunc.fixturenames:
563-
return
564-
fixturemanager = metafunc.config.pluginmanager.get_plugin("funcmanage")
565-
assert fixturemanager is not None
566-
# Add the scoped event loop fixture to Metafunc's list of fixture names and
567-
# fixturedefs and leave the actual parametrization to pytest
568-
# The fixture needs to be appended to avoid messing up the fixture evaluation
569-
# order
570-
metafunc.fixturenames.append(runner_fixture_id)
571-
metafunc._arg2fixturedefs[runner_fixture_id] = fixturemanager._arg2fixturedefs[
572-
runner_fixture_id
573-
]
574-
575-
576549
def _get_event_loop_policy() -> AbstractEventLoopPolicy:
577550
with warnings.catch_warnings():
578551
warnings.simplefilter("ignore", DeprecationWarning)

tests/markers/test_function_scope.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ async def test_warns():
8888
)
8989
)
9090
result = pytester.runpytest_subprocess("--asyncio-mode=strict")
91-
result.assert_outcomes(passed=1, warnings=2)
91+
result.assert_outcomes(passed=1, warnings=1)
9292
result.stdout.fnmatch_lines("*DeprecationWarning*")
9393

9494

0 commit comments

Comments
 (0)