-
Notifications
You must be signed in to change notification settings - Fork 159
asyncio_mode=auto does not mark static methods #292
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
Comments
Thanks for letting us know! In fact, this has already been reported in #265. We decided to close that issue, because we thought the majority of users can opt to not use static test methods. Is there any benefit of decorating tests with |
We have expensive pytest fixtures and we are using test classes to make use of "class" fixture scope. With it, we can control precisely when the teardown code is executed inside a test module. I wouldn't mind if the problem is not fixed, we added an explicit asyncio mark to affected staticmethod tests. From what I investigated when reporting the issue, while obj is of type Edit: fixed code sample, inspect.iscoroutinefunction() is to be called on item.function. |
@kriek would you propose a patch? |
I will give it a try. |
PR 295 created. I found the staticmethod unwrapping code by inspecting pytest sources. |
… to version 0.18.2 Andrew Svetlov (1): Update changelog Michael Seifert (2): fix: Add positional arguments to the synchronous test function wrapper. (#303) docs: Prepare release 0.18.2. (#304) dependabot[bot] (2): Bump actions/setup-python from 2 to 3 (#300) Bump actions/checkout from 2 to 3 (#301) kriek (1): Fix asyncio auto mode not marking static methods (closes pytest-dev/pytest-asyncio#265, closes pytest-dev/pytest-asyncio#292). (#295)
Hi there,
I've migrated from 0.17.2 to 0.18.1 and activated auto asyncio_mode. It seems the mode is not able to apply asyncio marker to static methods.
The following minimized example:
Fails as follows:
test_auto_mode.py could easily be extended to cover that extra use case but I am not sure how to adapt pytest_pycollect_makeitem to fix the problem.
As a side note, with 0.17.2, we were doing our own auto mode with the following code and it was working for functions, methods and static methods:
The text was updated successfully, but these errors were encountered: