mirror of https://github.com/tiangolo/fastapi.git
update required field test for Pydantic v1
Signed-off-by: merlinz01 <158784988+merlinz01@users.noreply.github.com>
This commit is contained in:
parent
f433590560
commit
78b49ac9ae
|
|
@ -2,6 +2,7 @@ import sys
|
|||
from typing import Optional, Union
|
||||
|
||||
import pytest
|
||||
from dirty_equals import IsDict
|
||||
from fastapi import Body, FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
|
@ -72,7 +73,8 @@ def test_apis(api):
|
|||
def test_required_field():
|
||||
response = client.post("/api5", json={"integer": None})
|
||||
assert response.status_code == 422, response.text
|
||||
assert response.json() == {
|
||||
assert response.json() == IsDict(
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"loc": ["body", "integer"],
|
||||
|
|
@ -82,3 +84,14 @@ def test_required_field():
|
|||
}
|
||||
]
|
||||
}
|
||||
) | IsDict(
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"loc": ["body", "integer"],
|
||||
"msg": "field required",
|
||||
"type": "value_error.missing",
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue