Skip to content

Deprecate aiohttp.pytest_plugin #10785

New issue

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

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

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: 3.12
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions aiohttp/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

"aiohttp.pytest_plugin will be removed in v4. Please install pytest-aiohttp.",
DeprecationWarning,
)
existing_loop = pyfuncitem.funcargs.get(
"proactor_loop"
) or pyfuncitem.funcargs.get("loop", None)
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ addopts =

# run tests that are not marked with dev_mode
-m "not dev_mode"
asyncio_mode = auto
filterwarnings =
error
ignore:module 'ssl' has no attribute 'OP_NO_COMPRESSION'. The Python interpreter is compiled against OpenSSL < 1.0.0. Ref. https.//docs.python.org/3/library/ssl.html#ssl.OP_NO_COMPRESSION:UserWarning
Expand Down
Loading