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 .main import app
@ -291,30 +290,17 @@ def test_path_param_min_maxlength_foobar():
def test_path_param_min_maxlength_f():
response = client.get("/path/param-min_maxlength/f")
assert response.status_code == 422
assert response.json() == IsDict(
{
"detail": [
{
"type": "string_too_short",
"loc": ["path", "item_id"],
"msg": "String should have at least 2 characters",
"input": "f",
"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},
}
]
}
)
assert response.json() == {
"detail": [
{
"type": "string_too_short",
"loc": ["path", "item_id"],
"msg": "String should have at least 2 characters",
"input": "f",
"ctx": {"min_length": 2},
}
]
}
def test_path_param_gt_42():

21
tests/test_union_body_discriminator.py

@ -1,6 +1,5 @@
from typing import Annotated, Any, Union
from dirty_equals import IsDict
from fastapi import FastAPI
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
@ -90,21 +89,11 @@ def test_discriminator_pydantic_v2() -> None:
"description": "Successful Response",
"content": {
"application/json": {
"schema": IsDict(
{
# 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",
"additionalProperties": True,
"title": "Response Save Union Body Discriminator Items Post",
}
)
"schema": {
"type": "object",
"additionalProperties": True,
"title": "Response Save Union Body Discriminator Items Post",
}
}
},
},

Loading…
Cancel
Save