fix(test): FastAPI 0.87.0 - error fixes

FastAPI 0.87.0 switched to the httpx library for their TestClient

* allow_redirects is deprecated and replaced by follow_redirects

Signed-off-by: moson-mo <mo-son@mailbox.org>
This commit is contained in:
moson-mo 2022-11-24 22:23:37 +01:00
parent 512ba02389
commit 1216399d53
No known key found for this signature in database
GPG key ID: 4A4760AB4EE15296
8 changed files with 218 additions and 226 deletions

View file

@ -20,7 +20,11 @@ def setup(db_test):
@pytest.fixture
def client() -> TestClient:
yield TestClient(app=app)
client = TestClient(app=app)
# disable redirects for our tests
client.follow_redirects = False
yield client
@pytest.fixture
@ -66,7 +70,7 @@ def test_favicon(client: TestClient):
"""Test the favicon route at '/favicon.ico'."""
with client as request:
response1 = request.get("/static/images/favicon.ico")
response2 = request.get("/favicon.ico")
response2 = request.get("/favicon.ico", follow_redirects=True)
assert response1.status_code == int(HTTPStatus.OK)
assert response1.content == response2.content