Coverage for tests/test_tutorial/test_additional_status_codes/test_tutorial001.py: 100%
17 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-12-04 08:29 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-12-04 08:29 +0000
1import importlib 1abcdefg
3import pytest 1abcdefg
4from fastapi.testclient import TestClient 1abcdefg
6from ...utils import needs_py39, needs_py310 1abcdefg
9@pytest.fixture( 1abcdefg
10 name="client",
11 params=[
12 "tutorial001",
13 pytest.param("tutorial001_py310", marks=needs_py310),
14 "tutorial001_an",
15 pytest.param("tutorial001_an_py39", marks=needs_py39),
16 pytest.param("tutorial001_an_py310", marks=needs_py310),
17 ],
18)
19def get_client(request: pytest.FixtureRequest): 1abcdefg
20 mod = importlib.import_module(f"docs_src.additional_status_codes.{request.param}") 1abcdefg
22 client = TestClient(mod.app) 1abcdefg
23 return client 1abcdefg
26def test_update(client: TestClient): 1abcdefg
27 response = client.put("/items/foo", json={"name": "Wrestlers"}) 1hijklmn
28 assert response.status_code == 200, response.text 1hijklmn
29 assert response.json() == {"name": "Wrestlers", "size": None} 1hijklmn
32def test_create(client: TestClient): 1abcdefg
33 response = client.put("/items/red", json={"name": "Chillies"}) 1opqrstu
34 assert response.status_code == 201, response.text 1opqrstu
35 assert response.json() == {"name": "Chillies", "size": None} 1opqrstu