pre-commit-ci-lite[bot]
4 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
3 additions and
1 deletions
-
tests/test_tutorial/test_path_params/test_tutorial006.py
|
|
@ -3,10 +3,12 @@ from fastapi.testclient import TestClient |
|
|
|
|
|
|
|
|
app = FastAPI() |
|
|
app = FastAPI() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/items/{item_id}") |
|
|
@app.get("/items/{item_id}") |
|
|
def read_item(item_id: int = Path(..., ge=1, le=1000)): |
|
|
def read_item(item_id: int = Path(..., ge=1, le=1000)): |
|
|
return {"item_id": item_id} |
|
|
return {"item_id": item_id} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
client = TestClient(app) |
|
|
client = TestClient(app) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -28,4 +30,4 @@ def test_item_id_above_range(): |
|
|
|
|
|
|
|
|
def test_invalid_type(): |
|
|
def test_invalid_type(): |
|
|
response = client.get("/items/abc") |
|
|
response = client.get("/items/abc") |
|
|
assert response.status_code == 422 # type validation error |
|
|
assert response.status_code == 422 # type validation error |
|
|
|