Skip to content

async fixtures are incompatible with pytest 3.7.0 #89

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

Closed
brycedrennan opened this issue Jul 31, 2018 · 7 comments · Fixed by pytest-dev/pytest#3754
Closed

async fixtures are incompatible with pytest 3.7.0 #89

brycedrennan opened this issue Jul 31, 2018 · 7 comments · Fixed by pytest-dev/pytest#3754

Comments

@brycedrennan
Copy link

Not sure exactly what the issue is yet but test suite passes in pytest==3.6.* but fails in the very recently released pytest 3.7.0.

@Gr1N
Copy link

Gr1N commented Jul 31, 2018

Got same issue, any ideas?

@brycedrennan
Copy link
Author

For now I've just pinned my pytest to 3.6.4

@jwldk
Copy link

jwldk commented Jul 31, 2018

Same problem here. Get this error:

E TypeError: 'coroutine' object is not subscriptable

when trying to use a async fixture in a test. Works with pytest 3.6.4. Doesn't even appear to be anything related in the pytest changelog.

@JohanLorenzo
Copy link

I got a similar error. I filed this issue in pytest pytest-dev/pytest#3747 (more details in there). @RonnyPfannschmidt suggested to open an issue over here. I put up a minimal test case https://github.com/JohanLorenzo/pytest-fixture-bug-3747. Please let me know if I can provide more details.

@RonnyPfannschmidt
Copy link
Member

@jwldk fixture definition changed in pytest to give a deprecationwarning on non-fixture usage, this issue is a collateral of that

@nicoddemus
Copy link
Member

I investigated and here's the problem:

@pytest.hookimpl(hookwrapper=True)
def pytest_fixture_setup(fixturedef, request):
"""Adjust the event loop policy when an event loop is produced."""
if isasyncgenfunction(fixturedef.func):
# This is an async generator function. Wrap it accordingly.
f = fixturedef.func

In pytest 3.7.0 fixturef.func is the "wrapped" function (which issues the warning when calling directly), which is not a coroutine/async function. This of course breaks this code.

@RonnyPfannschmidt unless we find a solution to this I'm considering reverting the wrapping code. pytest-asyncio probably is not the only plugin that will break because of this I'm afraid. 😟

@nicoddemus
Copy link
Member

Opened a tentative PR at pytest-dev/pytest#3754

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants