Skip to content

Deprecate aiohttp.pytest_plugin #10785

New issue

Have a question about this project? Sign up for a free account to open an issue and contact its maintainers and the community.

By clicking “Sign up for ”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on ? Sign in to your account

Draft
wants to merge 3 commits into
base: 3.12
Choose a base branch
from
Draft

Deprecate aiohttp.pytest_plugin #10785

wants to merge 3 commits into from

Conversation

Dreamsorcerer
Copy link
Member

Add deprecation warning in 3.12.

@DreamsorcererDreamsorcerer added the backport:skipSkip backport botlabel Apr 21, 2025
@codecovCodecov
Copy link

codecov bot commented Apr 21, 2025

❌ 1 Tests Failed:

Tests completedFailedPassedSkipped
1100
View the top 1 failed test(s) by shortest run time
pytest internal
Stack Traces | 0s run time
Traceback (most recent call last):
  File ".../hostedtoolcache/Python/3.9.22........................................../x64/lib/python3.9....../site-packages/_pytest/main.py", line 283, in wrap_session
    session.exitstatus = doit(config, session) or 0
  File ".../hostedtoolcache/Python/3.9.22........................................../x64/lib/python3.9....../site-packages/_pytest/main.py", line 336, in _main
    config.hook.pytest_collection(session=session)
  File ".../hostedtoolcache/Python/3.9.22........................................../x64/lib/python3.9.../site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File ".../hostedtoolcache/Python/3.9.22........................................../x64/lib/python3.9.../site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File ".../hostedtoolcache/Python/3.9.22........................................../x64/lib/python3.9............/site-packages/pluggy/_callers.py", line 139, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File ".../hostedtoolcache/Python/3.9.22........................................../x64/lib/python3.9............/site-packages/pluggy/_callers.py", line 122, in _multicall
    teardown.throw(exception)  # type: ignore[union-attr]
  File ".../hostedtoolcache/Python/3.9.22........................................../x64/lib/python3.9.../site-packages/_pytest/logging.py", line 790, in pytest_collection
    return (yield)
  File ".../hostedtoolcache/Python/3.9.22........................................../x64/lib/python3.9............/site-packages/pluggy/_callers.py", line 122, in _multicall
    teardown.throw(exception)  # type: ignore[union-attr]
  File ".../hostedtoolcache/Python/3.9.22........................................../x64/lib/python3.9.../site-packages/_pytest/warnings.py", line 121, in pytest_collection
    return (yield)
  File ".../hostedtoolcache/Python/3.9.22........................................../x64/lib/python3.9............/site-packages/pluggy/_callers.py", line 124, in _multicall
    teardown.send(result)  # type: ignore[union-attr]
  File ".../hostedtoolcache/Python/3.9.22........................................../x64/lib/python3.9.../_pytest/config/__init__.py", line 1419, in pytest_collection
    self._validate_config_options()
  File ".../hostedtoolcache/Python/3.9.22........................................../x64/lib/python3.9.../_pytest/config/__init__.py", line 1441, in _validate_config_options
    self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
  File ".../hostedtoolcache/Python/3.9.22........................................../x64/lib/python3.9.../_pytest/config/__init__.py", line 1480, in _warn_or_fail_if_strict
    self.issue_config_time_warning(PytestConfigWarning(message), stacklevel=3)
  File ".../hostedtoolcache/Python/3.9.22........................................../x64/lib/python3.9.../_pytest/config/__init__.py", line 1532, in issue_config_time_warning
    warnings.warn(warning, stacklevel=stacklevel)
pytest.PytestConfigWarning: Unknown config option: asyncio_mode

To view more test analytics, go to the Test Analytics Dasard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@@ -208,6 +208,10 @@ def pytest_pyfunc_call(pyfuncitem): # type: ignore[no-untyped-def]
"""Run coroutines in an event loop instead of a normal function call."""
fast = pyfuncitem.config.getoption("--aiohttp-fast")
if inspect.iscoroutinefunction(pyfuncitem.function):
warnings.warn(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this have a stacklevel=999?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would just remove the stack trace, right? I wasn't sure the best approach, given the user's code will not be in the stack trace.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it would point to this plugin module as the source, which is probably not the best thing to see. Also note that deprecation warnings aren't displayed by default (which is why some projects go for UserWarning instead). The end-users would need to have filterwarnings = error set in their pytest.ini to be able to see this — it may end up going unnoticed until they actually hit the removed thing. So I'm a bit turn here as (Future/Pending)DeprecationWarning is semantically more accurate but puts us at risk of not notifying enough end-users.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too worried as users should probably expect to make some changes when upgrading to v4. If they only notice at that point, that's fine.

@DreamsorcererDreamsorcerer marked this pull request as draft April 22, 2025 11:56
Sign up for free to join this conversation on . Already have an account? Sign in to comment
Labels
backport:skipSkip backport bot
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants