TestClient Fails to Call Endpoint with OAuth2PasswordRequestForm Using APIRouter #11802
Unanswered
IlyaMichlin
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
I encountered an issue when creating an endpoint that includes OAuth2PasswordRequestForm in its arguments and is described using @router.post(). The endpoint call breaks when using TestClient, though the code works fine when running the app with uvicorn.
When attempting to run the test using TestClient, the following error is encountered:
AttributeError: 'ProactorEventLoop' object has no attribute '_compute_internal_coro'
.The endpoint functions correctly when the app is executed with uvicorn. The issue only occurs when the endpoint is defined using @router.post(). Changing @router.post() to @app.post() resolves the issue.
Has anyone experienced a similar issue? Any insights or solutions would be greatly appreciated.
Operating System
Linux, Windows
Operating System Details
No response
FastAPI Version
0.111.0
Pydantic Version
2.8.2
Python Version
3.12.4
Additional Context
fastapi==0.111.0
httpx==0.27.0
pytest
Beta Was this translation helpful? Give feedback.
All reactions