mirror of
https://github.com/fastapi/fastapi.git
synced 2026-04-26 09:52:26 -04:00
🔥 Remove Pydantic v1 specific test variants (#14611)
This commit is contained in:
committed by
GitHub
parent
8322a4445a
commit
44c849c4fc
@@ -1,4 +1,3 @@
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.path_params.tutorial005_py39 import app
|
||||
@@ -27,31 +26,17 @@ def test_get_enums_resnet():
|
||||
def test_get_enums_invalid():
|
||||
response = client.get("/models/foo")
|
||||
assert response.status_code == 422
|
||||
assert response.json() == IsDict(
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"type": "enum",
|
||||
"loc": ["path", "model_name"],
|
||||
"msg": "Input should be 'alexnet', 'resnet' or 'lenet'",
|
||||
"input": "foo",
|
||||
"ctx": {"expected": "'alexnet', 'resnet' or 'lenet'"},
|
||||
}
|
||||
]
|
||||
}
|
||||
) | IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"ctx": {"enum_values": ["alexnet", "resnet", "lenet"]},
|
||||
"loc": ["path", "model_name"],
|
||||
"msg": "value is not a valid enumeration member; permitted: 'alexnet', 'resnet', 'lenet'",
|
||||
"type": "type_error.enum",
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
assert response.json() == {
|
||||
"detail": [
|
||||
{
|
||||
"type": "enum",
|
||||
"loc": ["path", "model_name"],
|
||||
"msg": "Input should be 'alexnet', 'resnet' or 'lenet'",
|
||||
"input": "foo",
|
||||
"ctx": {"expected": "'alexnet', 'resnet' or 'lenet'"},
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def test_openapi_schema():
|
||||
@@ -106,22 +91,11 @@ def test_openapi_schema():
|
||||
}
|
||||
},
|
||||
},
|
||||
"ModelName": IsDict(
|
||||
{
|
||||
"title": "ModelName",
|
||||
"enum": ["alexnet", "resnet", "lenet"],
|
||||
"type": "string",
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
{
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
"title": "ModelName",
|
||||
"enum": ["alexnet", "resnet", "lenet"],
|
||||
"type": "string",
|
||||
"description": "An enumeration.",
|
||||
}
|
||||
),
|
||||
"ModelName": {
|
||||
"title": "ModelName",
|
||||
"enum": ["alexnet", "resnet", "lenet"],
|
||||
"type": "string",
|
||||
},
|
||||
"ValidationError": {
|
||||
"title": "ValidationError",
|
||||
"required": ["loc", "msg", "type"],
|
||||
|
||||
Reference in New Issue
Block a user