-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
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
Flask 2.2.2 crashes with pytest-asyncio 0.19.0 #4773
Comments
Flask 2.2 has compatibility issues with pytest-asyncio (pallets/flask#4773), but it turns out we don't even need our tests to be async here. So we just use sync tests to fix the CI issues.
Don't do this, this is an invalid pattern. @pytest.fixture
def client():
with app.test_client() as client:
yield client Instead, push a test client only for exactly as long as you need to preserve the context for a request from that client. Note that you only need @pytest.fixture
def client(app):
return app.test_client()
def test_foo(client):
with client:
response = client.post("/api")
assert flask.request.method == "POST" Other than that, I have no idea how pytest-asyncio operates. If the above is not the cause of the issue then it sounds like they're doing something unexpected with context vars. Please report it there first to determine what we need to fix if so. |
There is a known issue with pytest-asyncio whereby contextvars are not propagated from a fixture, see pytest-dev/pytest-asyncio#127 and pallets/quart#149 |
Flask 2.2 has compatibility issues with pytest-asyncio (pallets/flask#4773), but it turns out we don't even need our tests to be async here. So we just use sync tests to fix the CI issues.
Flask 2.2 crashes with a
LookupError
on async test cases when usingpytest-asyncio
:The same code works fine with Flask 2.1. Thank you for your maintenance efforts! 😃
The text was updated successfully, but these errors were encountered: