-
-
Notifications
You must be signed in to change notification settings - Fork 7k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
starlette.TestClient with Jinja2Templates and middleware #806
Comments
This is related issue, in starlette, maybe... Hmm.. this is strange, maybe. Somehow, message["type"] is not "http.response.start", in starlette's middleware. actual value is like below.
So, assertion error occured in this line but async-asgi-testclient is okWriting similar tests, using async-asgi-testclient , test is passed. import pytest
@pytest.mark.asyncio
async def test_middleware2():
from async_asgi_testclient import TestClient
async with TestClient(app) as client:
response = await client.get("/")
assert "X-Process-Time" in response.headers then, message value is below
|
You are right @podhmo, the problem is with starlette and not with fastapi. Also, using async-asgi-testclient permits testing the application until starlette's test client is fixed. |
OK. I understood completely. This is the same issue as encode/starlette#472
So, test is failed. |
Thanks for the help here @podhmo ! 👏 🙇 Thanks for reporting back and closing the issue @bloomingmath 👍 |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Describe the bug
The problem arise when using starlette TestClient to get a template response that passes through a middleware.
To Reproduce
I made a repo with the minimal fastapi app to raise the error:
https://github.com/bloomingmath/fastapi-middleware-issue
To reproduce, clone the repo and run
pytest main.py
Expected behavior
I expect the test to run flawlessly, but it raise AssertionError as shown in the readme.md of the same repo.
Environment
The text was updated successfully, but these errors were encountered: