Coverage for tests / test_tutorial / test_additional_status_codes / test_tutorial001.py: 100%
17 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
1import importlib 1abdc
3import pytest 1abdc
4from fastapi.testclient import TestClient 1abdc
6from ...utils import needs_py310 1abdc
9@pytest.fixture( 1abdc
10 name="client",
11 params=[
12 pytest.param("tutorial001_py310", marks=needs_py310),
13 pytest.param("tutorial001_an_py310", marks=needs_py310),
14 ],
15)
16def get_client(request: pytest.FixtureRequest): 1abdc
17 mod = importlib.import_module(f"docs_src.additional_status_codes.{request.param}") 1abc
19 client = TestClient(mod.app) 1abc
20 return client 1abc
23def test_update(client: TestClient): 1abdc
24 response = client.put("/items/foo", json={"name": "Wrestlers"}) 1efg
25 assert response.status_code == 200, response.text 1efg
26 assert response.json() == {"name": "Wrestlers", "size": None} 1efg
29def test_create(client: TestClient): 1abdc
30 response = client.put("/items/red", json={"name": "Chillies"}) 1hij
31 assert response.status_code == 201, response.text 1hij
32 assert response.json() == {"name": "Chillies", "size": None} 1hij