Open LukeWood opened 1 year ago
More details needed,pytest notifies when async tests are there without a async plugin
More details needed,pytest notifies when async tests are there without a async plugin
Oh interesting! I had no idea- maybe I missed it in the logs?
what does notify mean in this context? Error or warning? If a warning maybe we should upgrade it to an error and gate the warning behind an environment variable?
Warnings
Thanks
Maybe we should consider upgrading the default and allow opt out via a config variable?
On Wed, Aug 30, 2023 at 12:16 PM Ronny Pfannschmidt < @.***> wrote:
Warnings
— Reply to this email directly, view it on GitHub https://github.com/pytest-dev/pytest/issues/11372#issuecomment-1699472606, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC5AMR6743UNPSTTBLSERKTXX5RMFANCNFSM6AAAAAA4EU5UJQ . You are receiving this because you authored the thread.Message ID: @.***>
-- Sent from mobile, Please excuse any typos.
@nicoddemus @asottile @bluetech
I'm +1 on turning those into a failure for 8.x and would like your input
Sounds good to me - we could even recommend a particular plugin based on sys.modules
:
if pkgs := " or ".join(
f"pytest-{n}" for n in ("anyio", "asyncio", "trio)
if n in sys.modules and f"pytest_{n}" not in sys.modules
):
error_msg += " Consider installing {pkgs}."
What's the problem this feature will solve?
When writing async unit-tests, it is extremely easy to forget to install the pytest-async extension and end up ignoring the futures.
This can cause unexpected silence:
This passes if pytest-async is not installed. Instead, I'd like to propose we make this fail with a nice message indicating that you need too install python-async.
Describe the solution you'd like
I'd like to inspect tests to see if they return a future. If they return a future, and pytest-async is not installed i'd like to error out and tell users to install it.
Alternative Solutions
Ignore the tests.
Additional context
I've been bit by this once~ know another team member of mine who has also been bitten by this. I'm happy to contribute this.