mirror of
https://github.com/fastapi/fastapi.git
synced 2026-10-27 04:09:37 -04:00
⬆ 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:
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
|
||||
Reference in new issue
Block a user