Replies: 2 comments
-
|
@Insolites I fixed it by changing the decorator: but for sure the FastAPI docs should be updated. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Also, if you want to set this for different scopes (other than on the function level via a decorator): |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
This is due to this change: https://fastapi.tiangolo.com/release-notes/?h=trio#0690
Pytest's AnyIO plugin will try to run tests on all supported backends: https://anyio.readthedocs.io/en/stable/testing.html#specifying-the-backends-to-run-on
Unfortunately if you install FastAPI the usual way and don't explicitly install
trio, then you don't actually have all the supported backends.So if you simply follow the instructions for running async tests then you will get a really huge stack trace with:
A possible solution as described here and in the anyio docs is to add a
conftest.pyto select just theasynciobackend:If there's any way this could be done helpfully/magically by FastAPI that would be great, if not it should be mentioned in the documentation.
Operating System
Linux
Operating System Details
No response
FastAPI Version
0.110.0
Pydantic Version
2.6.4
Python Version
Python 3.11.6
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions