Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions tests/test_tutorial/test_schema_extra_example/test_tutorial001.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import importlib

import pytest
from fastapi.testclient import TestClient

from ...utils import needs_pydanticv2
from ...utils import needs_py310, needs_pydanticv2


@pytest.fixture(name="client")
def get_client():
from docs_src.schema_extra_example.tutorial001 import app
@pytest.fixture(
name="client",
params=[
"tutorial001",
pytest.param("tutorial001_py310", marks=needs_py310),
],
)
def get_client(request: pytest.FixtureRequest):
mod = importlib.import_module(f"docs_src.schema_extra_example.{request.param}")

client = TestClient(app)
client = TestClient(mod.app)
return client


Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import importlib

import pytest
from fastapi.testclient import TestClient

from ...utils import needs_pydanticv1
from ...utils import needs_py310, needs_pydanticv1


@pytest.fixture(name="client")
def get_client():
from docs_src.schema_extra_example.tutorial001_pv1 import app
@pytest.fixture(
name="client",
params=[
"tutorial001_pv1",
pytest.param("tutorial001_pv1_py310", marks=needs_py310),
],
)
def get_client(request: pytest.FixtureRequest):
mod = importlib.import_module(f"docs_src.schema_extra_example.{request.param}")

client = TestClient(app)
client = TestClient(mod.app)
return client


Expand Down

This file was deleted.

This file was deleted.

27 changes: 22 additions & 5 deletions tests/test_tutorial/test_schema_extra_example/test_tutorial004.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
import importlib

import pytest
from dirty_equals import IsDict
from fastapi.testclient import TestClient

from docs_src.schema_extra_example.tutorial004 import app
from ...utils import needs_py39, needs_py310


@pytest.fixture(
name="client",
params=[
"tutorial004",
pytest.param("tutorial004_py310", marks=needs_py310),
"tutorial004_an",
pytest.param("tutorial004_an_py39", marks=needs_py39),
pytest.param("tutorial004_an_py310", marks=needs_py310),
],
)
def get_client(request: pytest.FixtureRequest):
mod = importlib.import_module(f"docs_src.schema_extra_example.{request.param}")

client = TestClient(app)
client = TestClient(mod.app)
return client


# Test required and embedded body parameters with no bodies sent
def test_post_body_example():
def test_post_body_example(client: TestClient):
response = client.put(
"/items/5",
json={
Expand All @@ -20,7 +37,7 @@ def test_post_body_example():
assert response.status_code == 200


def test_openapi_schema():
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == {
Expand Down
Loading
Loading