We have a FastApi app and using httpx AsyncClient for testing purposes. We are experiencing a problem where the unit tests run locally fine but fail on the CI server (Github Actions).
After further research we have come across this proposed solution by setting raise_server_exceptions=False
to False
.
client = TestClient(app, raise_server_exceptions=False)
However this is for the sync client. We are using the async client.
@pytest.fixture
async def client(test_app):
async with AsyncClient(app=test_app, base_url="http://testserver") as client:
yield client
The AsyncClient does not support the raise_app_exceptions=False
option.
Does anyone have experience with this? Thanks
The problem is caused by FastApi version. You can use fastapi==0.65.0
and even without the ASGITransport object and the raise_app_exceptions=False
flag you will be able to run the tests which are checking for custom exception raising.
Also the fastapi version should be frozen in the requirements file.
You can read more here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With