⬆ Upgrade Starlette to 0.21.0, including the new [TestClient based on HTTPX](https://github.com/encode/starlette/releases/tag/0.21.0) (#5471)

Co-authored-by: Paweł Rubin <pawel.rubin@ocado.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
authored and GitHub committed 2022-11-13 15:26:09 +01:00
1 parent 5f67ac6fd6
commit fdbd48be5f
26 files changed
+79 -73

No files matched your search

@@ -3,8 +3,6 @@ from fastapi.testclient import TestClient
from docs_src.cookie_params.tutorial001 import app
client = TestClient(app)
openapi_schema = {
"openapi": "3.0.2",
"info": {"title": "FastAPI", "version": "0.1.0"},
@@ -88,6 +86,7 @@ openapi_schema = {
],
)
def test(path, cookies, expected_status, expected_response):
response = client.get(path, cookies=cookies)
client = TestClient(app, cookies=cookies)
response = client.get(path)
assert response.status_code == expected_status
assert response.json() == expected_response
@@ -70,14 +70,6 @@ openapi_schema = {
}
@pytest.fixture(name="client")
def get_client():
from docs_src.cookie_params.tutorial001_py310 import app
client = TestClient(app)
return client
@needs_py310
@pytest.mark.parametrize(
"path,cookies,expected_status,expected_response",
@@ -94,7 +86,10 @@ def get_client():
("/items", {"session": "cookiesession"}, 200, {"ads_id": None}),
],
)
def test(path, cookies, expected_status, expected_response, client: TestClient):
response = client.get(path, cookies=cookies)
def test(path, cookies, expected_status, expected_response):
from docs_src.cookie_params.tutorial001_py310 import app
client = TestClient(app, cookies=cookies)
response = client.get(path)
assert response.status_code == expected_status
assert response.json() == expected_response