mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-05 22:26:41 -04:00
📝 Update source examples and docs from Python 3.9 to 3.10 (#14900)
This commit is contained in:
committed by
GitHub
parent
d06ab3f5c7
commit
c9e2277d8b
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.additional_responses.tutorial001_py39 import app
|
||||
from docs_src.additional_responses.tutorial001_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ from tests.utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial002_py39"),
|
||||
pytest.param("tutorial002_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.additional_responses.tutorial003_py39 import app
|
||||
from docs_src.additional_responses.tutorial003_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ from tests.utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial004_py39"),
|
||||
pytest.param("tutorial004_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -9,9 +9,7 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
"tutorial001_py39",
|
||||
pytest.param("tutorial001_py310", marks=needs_py310),
|
||||
"tutorial001_an_py39",
|
||||
pytest.param("tutorial001_an_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.advanced_middleware.tutorial001_py39 import app
|
||||
from docs_src.advanced_middleware.tutorial001_py310 import app
|
||||
|
||||
|
||||
def test_middleware():
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.advanced_middleware.tutorial002_py39 import app
|
||||
from docs_src.advanced_middleware.tutorial002_py310 import app
|
||||
|
||||
|
||||
def test_middleware():
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.responses import PlainTextResponse
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.advanced_middleware.tutorial003_py39 import app
|
||||
from docs_src.advanced_middleware.tutorial003_py310 import app
|
||||
|
||||
|
||||
@app.get("/large")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from docs_src.async_tests.app_a_py39.test_main import test_root
|
||||
from docs_src.async_tests.app_a_py310.test_main import test_root
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
|
||||
@@ -8,7 +8,7 @@ from inline_snapshot import snapshot
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
"tutorial001_an_py39",
|
||||
"tutorial001_an_py310",
|
||||
],
|
||||
)
|
||||
def get_client(request: pytest.FixtureRequest):
|
||||
|
||||
@@ -3,7 +3,7 @@ from pathlib import Path
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.background_tasks.tutorial001_py39 import app
|
||||
from docs_src.background_tasks.tutorial001_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -11,9 +11,7 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
"tutorial002_py39",
|
||||
pytest.param("tutorial002_py310", marks=needs_py310),
|
||||
"tutorial002_an_py39",
|
||||
pytest.param("tutorial002_an_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.behind_a_proxy.tutorial001_py39 import app
|
||||
from docs_src.behind_a_proxy.tutorial001_py310 import app
|
||||
|
||||
client = TestClient(app, root_path="/api/v1")
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.behind_a_proxy.tutorial001_01_py39 import app
|
||||
from docs_src.behind_a_proxy.tutorial001_01_py310 import app
|
||||
|
||||
client = TestClient(
|
||||
app,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.behind_a_proxy.tutorial002_py39 import app
|
||||
from docs_src.behind_a_proxy.tutorial002_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.behind_a_proxy.tutorial003_py39 import app
|
||||
from docs_src.behind_a_proxy.tutorial003_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.behind_a_proxy.tutorial004_py39 import app
|
||||
from docs_src.behind_a_proxy.tutorial004_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -8,8 +8,7 @@ from inline_snapshot import snapshot
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
"app_py39.main",
|
||||
"app_an_py39.main",
|
||||
"app_an_py310.main",
|
||||
],
|
||||
)
|
||||
def get_client(request: pytest.FixtureRequest):
|
||||
|
||||
@@ -11,7 +11,6 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
"tutorial001_py39",
|
||||
pytest.param("tutorial001_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import importlib
|
||||
from typing import Union
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
@@ -11,7 +10,6 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial002_py39"),
|
||||
pytest.param("tutorial002_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
@@ -23,7 +21,7 @@ def get_client(request: pytest.FixtureRequest):
|
||||
|
||||
|
||||
@pytest.mark.parametrize("price", ["50.5", 50.5])
|
||||
def test_post_with_tax(client: TestClient, price: Union[str, float]):
|
||||
def test_post_with_tax(client: TestClient, price: str | float):
|
||||
response = client.post(
|
||||
"/items/",
|
||||
json={"name": "Foo", "price": price, "description": "Some Foo", "tax": 0.3},
|
||||
@@ -39,7 +37,7 @@ def test_post_with_tax(client: TestClient, price: Union[str, float]):
|
||||
|
||||
|
||||
@pytest.mark.parametrize("price", ["50.5", 50.5])
|
||||
def test_post_without_tax(client: TestClient, price: Union[str, float]):
|
||||
def test_post_without_tax(client: TestClient, price: str | float):
|
||||
response = client.post(
|
||||
"/items/", json={"name": "Foo", "price": price, "description": "Some Foo"}
|
||||
)
|
||||
|
||||
@@ -10,7 +10,6 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial003_py39"),
|
||||
pytest.param("tutorial003_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,7 +10,6 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial004_py39"),
|
||||
pytest.param("tutorial004_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,9 +10,7 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
"tutorial001_py39",
|
||||
pytest.param("tutorial001_py310", marks=needs_py310),
|
||||
"tutorial001_an_py39",
|
||||
pytest.param("tutorial001_an_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,9 +10,7 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
"tutorial001_py39",
|
||||
pytest.param("tutorial001_py310", marks=needs_py310),
|
||||
"tutorial001_an_py39",
|
||||
pytest.param("tutorial001_an_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,7 +10,6 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial002_py39"),
|
||||
pytest.param("tutorial002_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,9 +10,7 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
"tutorial003_py39",
|
||||
pytest.param("tutorial003_py310", marks=needs_py310),
|
||||
"tutorial003_an_py39",
|
||||
pytest.param("tutorial003_an_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,9 +10,7 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial004_py39"),
|
||||
pytest.param("tutorial004_py310", marks=needs_py310),
|
||||
pytest.param("tutorial004_an_py39"),
|
||||
pytest.param("tutorial004_an_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,9 +10,7 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial005_py39"),
|
||||
pytest.param("tutorial005_py310", marks=needs_py310),
|
||||
pytest.param("tutorial005_an_py39"),
|
||||
pytest.param("tutorial005_an_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -17,11 +17,8 @@ SET_OF_STR_SCHEMA = {"type": "array", "items": {"type": "string"}, "uniqueItems"
|
||||
@pytest.fixture(
|
||||
name="mod_name",
|
||||
params=[
|
||||
pytest.param("tutorial001_py39"),
|
||||
pytest.param("tutorial001_py310", marks=needs_py310),
|
||||
pytest.param("tutorial002_py39"),
|
||||
pytest.param("tutorial002_py310", marks=needs_py310),
|
||||
pytest.param("tutorial003_py39"),
|
||||
pytest.param("tutorial003_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -11,7 +11,6 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial004_py39"),
|
||||
pytest.param("tutorial004_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -11,7 +11,6 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial005_py39"),
|
||||
pytest.param("tutorial005_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -11,7 +11,6 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial006_py39"),
|
||||
pytest.param("tutorial006_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,7 +10,6 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial007_py39"),
|
||||
pytest.param("tutorial007_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ from inline_snapshot import snapshot
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial008_py39"),
|
||||
pytest.param("tutorial008_py310"),
|
||||
],
|
||||
)
|
||||
def get_client(request: pytest.FixtureRequest):
|
||||
|
||||
@@ -8,7 +8,7 @@ from inline_snapshot import snapshot
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
"tutorial009_py39",
|
||||
"tutorial009_py310",
|
||||
],
|
||||
)
|
||||
def get_client(request: pytest.FixtureRequest):
|
||||
|
||||
@@ -10,7 +10,6 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
"tutorial001_py39",
|
||||
pytest.param("tutorial001_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,7 +10,6 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial002_py39"),
|
||||
pytest.param("tutorial002_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -5,11 +5,11 @@ from inline_snapshot import snapshot
|
||||
|
||||
|
||||
def get_client() -> TestClient:
|
||||
from docs_src.conditional_openapi import tutorial001_py39
|
||||
from docs_src.conditional_openapi import tutorial001_py310
|
||||
|
||||
importlib.reload(tutorial001_py39)
|
||||
importlib.reload(tutorial001_py310)
|
||||
|
||||
client = TestClient(tutorial001_py39.app)
|
||||
client = TestClient(tutorial001_py310.app)
|
||||
return client
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.configure_swagger_ui.tutorial001_py39 import app
|
||||
from docs_src.configure_swagger_ui.tutorial001_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.configure_swagger_ui.tutorial002_py39 import app
|
||||
from docs_src.configure_swagger_ui.tutorial002_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.configure_swagger_ui.tutorial003_py39 import app
|
||||
from docs_src.configure_swagger_ui.tutorial003_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -10,9 +10,7 @@ from tests.utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
"tutorial001_py39",
|
||||
pytest.param("tutorial001_py310", marks=needs_py310),
|
||||
"tutorial001_an_py39",
|
||||
pytest.param("tutorial001_an_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,9 +10,7 @@ from tests.utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial002_py39"),
|
||||
pytest.param("tutorial002_py310", marks=[needs_py310]),
|
||||
pytest.param("tutorial002_an_py39"),
|
||||
pytest.param("tutorial002_an_py310", marks=[needs_py310]),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -11,9 +11,7 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="mod",
|
||||
params=[
|
||||
"tutorial001_py39",
|
||||
pytest.param("tutorial001_py310", marks=needs_py310),
|
||||
"tutorial001_an_py39",
|
||||
pytest.param("tutorial001_an_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.cors.tutorial001_py39 import app
|
||||
from docs_src.cors.tutorial001_py310 import app
|
||||
|
||||
|
||||
def test_cors():
|
||||
|
||||
@@ -10,7 +10,7 @@ def client():
|
||||
static_dir: Path = Path(os.getcwd()) / "static"
|
||||
print(static_dir)
|
||||
static_dir.mkdir(exist_ok=True)
|
||||
from docs_src.custom_docs_ui.tutorial001_py39 import app
|
||||
from docs_src.custom_docs_ui.tutorial001_py310 import app
|
||||
|
||||
with TestClient(app) as client:
|
||||
yield client
|
||||
|
||||
@@ -10,7 +10,7 @@ def client():
|
||||
static_dir: Path = Path(os.getcwd()) / "static"
|
||||
print(static_dir)
|
||||
static_dir.mkdir(exist_ok=True)
|
||||
from docs_src.custom_docs_ui.tutorial002_py39 import app
|
||||
from docs_src.custom_docs_ui.tutorial002_py310 import app
|
||||
|
||||
with TestClient(app) as client:
|
||||
yield client
|
||||
|
||||
@@ -12,9 +12,7 @@ from tests.utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial001_py39"),
|
||||
pytest.param("tutorial001_py310", marks=needs_py310),
|
||||
pytest.param("tutorial001_an_py39"),
|
||||
pytest.param("tutorial001_an_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,9 +10,7 @@ from tests.utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial002_py39"),
|
||||
pytest.param("tutorial002_py310", marks=needs_py310),
|
||||
pytest.param("tutorial002_an_py39"),
|
||||
pytest.param("tutorial002_an_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -9,7 +9,6 @@ from tests.utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial003_py39"),
|
||||
pytest.param("tutorial003_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -8,8 +8,8 @@ from inline_snapshot import snapshot
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial001_py39"),
|
||||
pytest.param("tutorial010_py39"),
|
||||
pytest.param("tutorial001_py310"),
|
||||
pytest.param("tutorial010_py310"),
|
||||
],
|
||||
)
|
||||
def get_client(request: pytest.FixtureRequest):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.custom_response.tutorial001b_py39 import app
|
||||
from docs_src.custom_response.tutorial001b_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ from inline_snapshot import Is, snapshot
|
||||
@pytest.fixture(
|
||||
name="mod_name",
|
||||
params=[
|
||||
pytest.param("tutorial002_py39"),
|
||||
pytest.param("tutorial003_py39"),
|
||||
pytest.param("tutorial004_py39"),
|
||||
pytest.param("tutorial002_py310"),
|
||||
pytest.param("tutorial003_py310"),
|
||||
pytest.param("tutorial004_py310"),
|
||||
],
|
||||
)
|
||||
def get_mod_name(request: pytest.FixtureRequest) -> str:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.custom_response.tutorial005_py39 import app
|
||||
from docs_src.custom_response.tutorial005_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.custom_response.tutorial006_py39 import app
|
||||
from docs_src.custom_response.tutorial006_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.custom_response.tutorial006b_py39 import app
|
||||
from docs_src.custom_response.tutorial006b_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.custom_response.tutorial006c_py39 import app
|
||||
from docs_src.custom_response.tutorial006c_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.custom_response.tutorial007_py39 import app
|
||||
from docs_src.custom_response.tutorial007_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -2,15 +2,15 @@ from pathlib import Path
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.custom_response import tutorial008_py39
|
||||
from docs_src.custom_response.tutorial008_py39 import app
|
||||
from docs_src.custom_response import tutorial008_py310
|
||||
from docs_src.custom_response.tutorial008_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_get(tmp_path: Path):
|
||||
file_path: Path = tmp_path / "large-video-file.mp4"
|
||||
tutorial008_py39.some_file_path = str(file_path)
|
||||
tutorial008_py310.some_file_path = str(file_path)
|
||||
test_content = b"Fake video bytes"
|
||||
file_path.write_bytes(test_content)
|
||||
response = client.get("/")
|
||||
|
||||
@@ -2,15 +2,15 @@ from pathlib import Path
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.custom_response import tutorial009_py39
|
||||
from docs_src.custom_response.tutorial009_py39 import app
|
||||
from docs_src.custom_response import tutorial009_py310
|
||||
from docs_src.custom_response.tutorial009_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_get(tmp_path: Path):
|
||||
file_path: Path = tmp_path / "large-video-file.mp4"
|
||||
tutorial009_py39.some_file_path = str(file_path)
|
||||
tutorial009_py310.some_file_path = str(file_path)
|
||||
test_content = b"Fake video bytes"
|
||||
file_path.write_bytes(test_content)
|
||||
response = client.get("/")
|
||||
|
||||
@@ -2,15 +2,15 @@ from pathlib import Path
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.custom_response import tutorial009b_py39
|
||||
from docs_src.custom_response.tutorial009b_py39 import app
|
||||
from docs_src.custom_response import tutorial009b_py310
|
||||
from docs_src.custom_response.tutorial009b_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_get(tmp_path: Path):
|
||||
file_path: Path = tmp_path / "large-video-file.mp4"
|
||||
tutorial009b_py39.some_file_path = str(file_path)
|
||||
tutorial009b_py310.some_file_path = str(file_path)
|
||||
test_content = b"Fake video bytes"
|
||||
file_path.write_bytes(test_content)
|
||||
response = client.get("/")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.custom_response.tutorial009c_py39 import app
|
||||
from docs_src.custom_response.tutorial009c_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ from tests.utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial001_py39"),
|
||||
pytest.param("tutorial001_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,7 +10,6 @@ from tests.utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial002_py39"),
|
||||
pytest.param("tutorial002_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,7 +10,6 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial003_py39"),
|
||||
pytest.param("tutorial003_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@ import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
MOD_NAME = "docs_src.debugging.tutorial001_py39"
|
||||
MOD_NAME = "docs_src.debugging.tutorial001_py310"
|
||||
|
||||
|
||||
@pytest.fixture(name="client")
|
||||
|
||||
@@ -10,11 +10,8 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial001_py39"),
|
||||
pytest.param("tutorial001_py310", marks=needs_py310),
|
||||
pytest.param("tutorial001_an_py39"),
|
||||
pytest.param("tutorial001_an_py310", marks=needs_py310),
|
||||
pytest.param("tutorial001_02_an_py39"),
|
||||
pytest.param("tutorial001_02_an_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,17 +10,11 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial002_py39"),
|
||||
pytest.param("tutorial002_py310", marks=needs_py310),
|
||||
pytest.param("tutorial002_an_py39"),
|
||||
pytest.param("tutorial002_an_py310", marks=needs_py310),
|
||||
pytest.param("tutorial003_py39"),
|
||||
pytest.param("tutorial003_py310", marks=needs_py310),
|
||||
pytest.param("tutorial003_an_py39"),
|
||||
pytest.param("tutorial003_an_py310", marks=needs_py310),
|
||||
pytest.param("tutorial004_py39"),
|
||||
pytest.param("tutorial004_py310", marks=needs_py310),
|
||||
pytest.param("tutorial004_an_py39"),
|
||||
pytest.param("tutorial004_an_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,9 +10,7 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial005_py39"),
|
||||
pytest.param("tutorial005_py310", marks=needs_py310),
|
||||
pytest.param("tutorial005_an_py39"),
|
||||
pytest.param("tutorial005_an_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -8,8 +8,8 @@ from inline_snapshot import snapshot
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial006_py39"),
|
||||
pytest.param("tutorial006_an_py39"),
|
||||
pytest.param("tutorial006_py310"),
|
||||
pytest.param("tutorial006_an_py310"),
|
||||
],
|
||||
)
|
||||
def get_client(request: pytest.FixtureRequest):
|
||||
|
||||
@@ -2,7 +2,7 @@ import asyncio
|
||||
from contextlib import asynccontextmanager
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from docs_src.dependencies.tutorial007_py39 import get_db
|
||||
from docs_src.dependencies.tutorial007_py310 import get_db
|
||||
|
||||
|
||||
def test_get_db(): # Just for coverage
|
||||
@@ -14,7 +14,7 @@ def test_get_db(): # Just for coverage
|
||||
dbsession_moock = Mock()
|
||||
|
||||
with patch(
|
||||
"docs_src.dependencies.tutorial007_py39.DBSession",
|
||||
"docs_src.dependencies.tutorial007_py310.DBSession",
|
||||
return_value=dbsession_moock,
|
||||
create=True,
|
||||
):
|
||||
|
||||
@@ -12,9 +12,9 @@ from fastapi.testclient import TestClient
|
||||
@pytest.fixture(
|
||||
name="module",
|
||||
params=[
|
||||
"tutorial008_py39",
|
||||
"tutorial008_py310",
|
||||
pytest.param(
|
||||
"tutorial008_an_py39",
|
||||
"tutorial008_an_py310",
|
||||
marks=pytest.mark.xfail(
|
||||
sys.version_info < (3, 14),
|
||||
reason="Fails with `NameError: name 'DepA' is not defined`",
|
||||
|
||||
@@ -7,8 +7,8 @@ from fastapi.testclient import TestClient
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial008b_py39"),
|
||||
pytest.param("tutorial008b_an_py39"),
|
||||
pytest.param("tutorial008b_py310"),
|
||||
pytest.param("tutorial008b_an_py310"),
|
||||
],
|
||||
)
|
||||
def get_client(request: pytest.FixtureRequest):
|
||||
|
||||
@@ -9,8 +9,8 @@ from fastapi.testclient import TestClient
|
||||
@pytest.fixture(
|
||||
name="mod",
|
||||
params=[
|
||||
pytest.param("tutorial008c_py39"),
|
||||
pytest.param("tutorial008c_an_py39"),
|
||||
pytest.param("tutorial008c_py310"),
|
||||
pytest.param("tutorial008c_an_py310"),
|
||||
],
|
||||
)
|
||||
def get_mod(request: pytest.FixtureRequest):
|
||||
|
||||
@@ -8,8 +8,8 @@ from fastapi.testclient import TestClient
|
||||
@pytest.fixture(
|
||||
name="mod",
|
||||
params=[
|
||||
pytest.param("tutorial008d_py39"),
|
||||
pytest.param("tutorial008d_an_py39"),
|
||||
pytest.param("tutorial008d_py310"),
|
||||
pytest.param("tutorial008d_an_py310"),
|
||||
],
|
||||
)
|
||||
def get_mod(request: pytest.FixtureRequest):
|
||||
|
||||
@@ -7,8 +7,8 @@ from fastapi.testclient import TestClient
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial008e_py39"),
|
||||
pytest.param("tutorial008e_an_py39"),
|
||||
pytest.param("tutorial008e_py310"),
|
||||
pytest.param("tutorial008e_an_py310"),
|
||||
],
|
||||
)
|
||||
def get_client(request: pytest.FixtureRequest):
|
||||
|
||||
@@ -4,7 +4,7 @@ from unittest.mock import Mock, patch
|
||||
from fastapi import Depends, FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.dependencies.tutorial010_py39 import get_db
|
||||
from docs_src.dependencies.tutorial010_py310 import get_db
|
||||
|
||||
|
||||
def test_get_db():
|
||||
@@ -19,7 +19,7 @@ def test_get_db():
|
||||
dbsession_mock = Mock()
|
||||
|
||||
with patch(
|
||||
"docs_src.dependencies.tutorial010_py39.DBSession",
|
||||
"docs_src.dependencies.tutorial010_py310.DBSession",
|
||||
return_value=dbsession_mock,
|
||||
create=True,
|
||||
):
|
||||
|
||||
@@ -8,8 +8,8 @@ from inline_snapshot import snapshot
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
"tutorial011_py39",
|
||||
pytest.param("tutorial011_an_py39"),
|
||||
"tutorial011_py310",
|
||||
pytest.param("tutorial011_an_py310"),
|
||||
],
|
||||
)
|
||||
def get_client(request: pytest.FixtureRequest):
|
||||
|
||||
@@ -8,8 +8,8 @@ from inline_snapshot import snapshot
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial012_py39"),
|
||||
pytest.param("tutorial012_an_py39"),
|
||||
pytest.param("tutorial012_py310"),
|
||||
pytest.param("tutorial012_an_py310"),
|
||||
],
|
||||
)
|
||||
def get_client(request: pytest.FixtureRequest):
|
||||
|
||||
@@ -11,7 +11,6 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="mod",
|
||||
params=[
|
||||
pytest.param("tutorial001_py39"),
|
||||
pytest.param("tutorial001_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@ from inline_snapshot import snapshot
|
||||
@pytest.fixture(name="app", scope="module")
|
||||
def get_app():
|
||||
with pytest.warns(DeprecationWarning):
|
||||
from docs_src.events.tutorial001_py39 import app
|
||||
from docs_src.events.tutorial001_py310 import app
|
||||
yield app
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ from inline_snapshot import snapshot
|
||||
@pytest.fixture(name="app", scope="module")
|
||||
def get_app():
|
||||
with pytest.warns(DeprecationWarning):
|
||||
from docs_src.events.tutorial002_py39 import app
|
||||
from docs_src.events.tutorial002_py310 import app
|
||||
yield app
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.events.tutorial003_py39 import (
|
||||
from docs_src.events.tutorial003_py310 import (
|
||||
app,
|
||||
fake_answer_to_everything_ml_model,
|
||||
ml_models,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.extending_openapi.tutorial001_py39 import app
|
||||
from docs_src.extending_openapi.tutorial001_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -10,9 +10,7 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial001_py39"),
|
||||
pytest.param("tutorial001_py310", marks=needs_py310),
|
||||
pytest.param("tutorial001_an_py39"),
|
||||
pytest.param("tutorial001_an_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -11,9 +11,7 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial001_py39"),
|
||||
pytest.param("tutorial001_py310", marks=needs_py310),
|
||||
pytest.param("tutorial002_py39"),
|
||||
pytest.param("tutorial002_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,7 +10,6 @@ from ...utils import needs_py310
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial003_py39"),
|
||||
pytest.param("tutorial003_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ from inline_snapshot import snapshot
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial004_py39"),
|
||||
pytest.param("tutorial004_py310"),
|
||||
],
|
||||
)
|
||||
def get_client(request: pytest.FixtureRequest):
|
||||
|
||||
@@ -8,7 +8,7 @@ from inline_snapshot import snapshot
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial005_py39"),
|
||||
pytest.param("tutorial005_py310"),
|
||||
],
|
||||
)
|
||||
def get_client(request: pytest.FixtureRequest):
|
||||
|
||||
@@ -8,8 +8,8 @@ from inline_snapshot import snapshot
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
"tutorial001_py39",
|
||||
"tutorial003_py39",
|
||||
"tutorial001_py310",
|
||||
"tutorial003_py310",
|
||||
],
|
||||
)
|
||||
def get_client(request: pytest.FixtureRequest):
|
||||
|
||||
@@ -8,7 +8,7 @@ from inline_snapshot import snapshot
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
pytest.param("tutorial001_py39"),
|
||||
pytest.param("tutorial001_py310"),
|
||||
],
|
||||
)
|
||||
def get_client(request: pytest.FixtureRequest):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.generate_clients.tutorial002_py39 import app
|
||||
from docs_src.generate_clients.tutorial002_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.generate_clients.tutorial003_py39 import app
|
||||
from docs_src.generate_clients.tutorial003_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -5,16 +5,16 @@ from unittest.mock import patch
|
||||
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.generate_clients import tutorial003_py39
|
||||
from docs_src.generate_clients import tutorial003_py310
|
||||
|
||||
|
||||
def test_remove_tags(tmp_path: pathlib.Path):
|
||||
tmp_file = tmp_path / "openapi.json"
|
||||
openapi_json = tutorial003_py39.app.openapi()
|
||||
openapi_json = tutorial003_py310.app.openapi()
|
||||
tmp_file.write_text(json.dumps(openapi_json))
|
||||
|
||||
with patch("pathlib.Path", return_value=tmp_file):
|
||||
importlib.import_module("docs_src.generate_clients.tutorial004_py39")
|
||||
importlib.import_module("docs_src.generate_clients.tutorial004_py310")
|
||||
|
||||
modified_openapi = json.loads(tmp_file.read_text())
|
||||
assert modified_openapi == snapshot(
|
||||
|
||||
@@ -10,7 +10,7 @@ warnings.filterwarnings(
|
||||
category=DeprecationWarning,
|
||||
)
|
||||
|
||||
from docs_src.graphql_.tutorial001_py39 import app # noqa: E402
|
||||
from docs_src.graphql_.tutorial001_py310 import app # noqa: E402
|
||||
|
||||
|
||||
@pytest.fixture(name="client")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.handling_errors.tutorial001_py39 import app
|
||||
from docs_src.handling_errors.tutorial001_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.handling_errors.tutorial002_py39 import app
|
||||
from docs_src.handling_errors.tutorial002_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.handling_errors.tutorial003_py39 import app
|
||||
from docs_src.handling_errors.tutorial003_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.handling_errors.tutorial004_py39 import app
|
||||
from docs_src.handling_errors.tutorial004_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from docs_src.handling_errors.tutorial005_py39 import app
|
||||
from docs_src.handling_errors.tutorial005_py310 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user