|
|
|
@ -3,16 +3,15 @@ import importlib |
|
|
|
import pytest |
|
|
|
from fastapi.testclient import TestClient |
|
|
|
|
|
|
|
from ...utils import needs_py310 |
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture( |
|
|
|
name="client", |
|
|
|
params=[ |
|
|
|
pytest.param("tutorial005_py39"), |
|
|
|
pytest.param("tutorial005_py310", marks=needs_py310), |
|
|
|
pytest.param("tutorial005_py310"), |
|
|
|
], |
|
|
|
) |
|
|
|
|
|
|
|
def get_client(request: pytest.FixtureRequest): |
|
|
|
mod = importlib.import_module(f"docs_src.body.{request.param}") |
|
|
|
client = TestClient(mod.app) |
|
|
|
@ -27,4 +26,6 @@ def test_required_nullable_field(client: TestClient): |
|
|
|
|
|
|
|
def test_required_field_missing(client: TestClient): |
|
|
|
response = client.post("/items/", json={}) |
|
|
|
assert response.status_code == 422 |
|
|
|
assert response.status_code == 200 |
|
|
|
assert response.json() == {"description": None} |
|
|
|
|