Browse Source

🔥 Remove more Pydantic v1 specific tests

pull/14611/head
Sebastián Ramírez 7 months ago
parent
commit
6b89781133
  1. 36
      tests/test_path.py
  2. 21
      tests/test_union_body_discriminator.py

36
tests/test_path.py

@ -1,4 +1,3 @@
from dirty_equals import IsDict
from fastapi.testclient import TestClient from fastapi.testclient import TestClient
from .main import app from .main import app
@ -291,30 +290,17 @@ def test_path_param_min_maxlength_foobar():
def test_path_param_min_maxlength_f(): def test_path_param_min_maxlength_f():
response = client.get("/path/param-min_maxlength/f") response = client.get("/path/param-min_maxlength/f")
assert response.status_code == 422 assert response.status_code == 422
assert response.json() == IsDict( assert response.json() == {
{ "detail": [
"detail": [ {
{ "type": "string_too_short",
"type": "string_too_short", "loc": ["path", "item_id"],
"loc": ["path", "item_id"], "msg": "String should have at least 2 characters",
"msg": "String should have at least 2 characters", "input": "f",
"input": "f", "ctx": {"min_length": 2},
"ctx": {"min_length": 2}, }
} ]
] }
}
) | IsDict(
{
"detail": [
{
"loc": ["path", "item_id"],
"msg": "ensure this value has at least 2 characters",
"type": "value_error.any_str.min_length",
"ctx": {"limit_value": 2},
}
]
}
)
def test_path_param_gt_42(): def test_path_param_gt_42():

21
tests/test_union_body_discriminator.py

@ -1,6 +1,5 @@
from typing import Annotated, Any, Union from typing import Annotated, Any, Union
from dirty_equals import IsDict
from fastapi import FastAPI from fastapi import FastAPI
from fastapi.testclient import TestClient from fastapi.testclient import TestClient
from inline_snapshot import snapshot from inline_snapshot import snapshot
@ -90,21 +89,11 @@ def test_discriminator_pydantic_v2() -> None:
"description": "Successful Response", "description": "Successful Response",
"content": { "content": {
"application/json": { "application/json": {
"schema": IsDict( "schema": {
{ "type": "object",
# Pydantic 2.10, in Python 3.8 "additionalProperties": True,
# TODO: remove when dropping support for Python 3.8 "title": "Response Save Union Body Discriminator Items Post",
"type": "object", }
"title": "Response Save Union Body Discriminator Items Post",
}
)
| IsDict(
{
"type": "object",
"additionalProperties": True,
"title": "Response Save Union Body Discriminator Items Post",
}
)
} }
}, },
}, },

Loading…
Cancel
Save