Browse Source

🔥 Remove more Pydantic v1 specific tests

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

16
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,8 +290,7 @@ 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",
@ -303,18 +301,6 @@ def test_path_param_min_maxlength_f():
} }
] ]
} }
) | 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():

13
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": {
{
# Pydantic 2.10, in Python 3.8
# TODO: remove when dropping support for Python 3.8
"type": "object",
"title": "Response Save Union Body Discriminator Items Post",
}
)
| IsDict(
{
"type": "object", "type": "object",
"additionalProperties": True, "additionalProperties": True,
"title": "Response Save Union Body Discriminator Items Post", "title": "Response Save Union Body Discriminator Items Post",
} }
)
} }
}, },
}, },

Loading…
Cancel
Save