Browse Source

🔥 Remove decorators of needs_pydanticv2

pull/14575/head
Sebastián Ramírez 7 months ago
parent
commit
444582270c
  1. 5
      tests/test_arbitrary_types.py
  2. 8
      tests/test_compat.py
  3. 4
      tests/test_computed_fields.py
  4. 4
      tests/test_datetime_custom_encoder.py
  5. 5
      tests/test_filter_pydantic_sub_model_pv2.py
  6. 4
      tests/test_inherited_custom_class.py
  7. 8
      tests/test_jsonable_encoder.py
  8. 5
      tests/test_openapi_separate_input_output_schemas.py
  9. 4
      tests/test_read_with_orm_mode.py
  10. 11
      tests/test_request_params/test_body/test_list.py
  11. 9
      tests/test_request_params/test_body/test_optional_list.py
  12. 15
      tests/test_request_params/test_body/test_optional_str.py
  13. 11
      tests/test_request_params/test_body/test_required_str.py
  14. 11
      tests/test_request_params/test_cookie/test_optional_str.py
  15. 11
      tests/test_request_params/test_cookie/test_required_str.py
  16. 11
      tests/test_request_params/test_file/test_list.py
  17. 11
      tests/test_request_params/test_file/test_optional.py
  18. 11
      tests/test_request_params/test_file/test_optional_list.py
  19. 11
      tests/test_request_params/test_file/test_required.py
  20. 11
      tests/test_request_params/test_form/test_list.py
  21. 11
      tests/test_request_params/test_form/test_optional_list.py
  22. 11
      tests/test_request_params/test_form/test_optional_str.py
  23. 11
      tests/test_request_params/test_form/test_required_str.py
  24. 11
      tests/test_request_params/test_header/test_list.py
  25. 11
      tests/test_request_params/test_header/test_optional_list.py
  26. 11
      tests/test_request_params/test_header/test_optional_str.py
  27. 11
      tests/test_request_params/test_header/test_required_str.py
  28. 11
      tests/test_request_params/test_query/test_list.py
  29. 11
      tests/test_request_params/test_query/test_optional_list.py
  30. 11
      tests/test_request_params/test_query/test_optional_str.py
  31. 11
      tests/test_request_params/test_query/test_required_str.py
  32. 4
      tests/test_schema_compat_pydantic_v2.py
  33. 4
      tests/test_schema_ref_pydantic_v2.py
  34. 3
      tests/test_tutorial/test_body_updates/test_tutorial001.py
  35. 5
      tests/test_tutorial/test_conditional_openapi/test_tutorial001.py
  36. 5
      tests/test_tutorial/test_dataclasses/test_tutorial003.py
  37. 3
      tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial004.py
  38. 6
      tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial007.py
  39. 3
      tests/test_tutorial/test_path_operation_configurations/test_tutorial005.py
  40. 9
      tests/test_tutorial/test_request_form_models/test_tutorial002.py
  41. 5
      tests/test_tutorial/test_response_directly/test_tutorial001.py
  42. 4
      tests/test_tutorial/test_schema_extra_example/test_tutorial001.py
  43. 3
      tests/test_tutorial/test_separate_openapi_schemas/test_tutorial001.py
  44. 3
      tests/test_tutorial/test_separate_openapi_schemas/test_tutorial002.py
  45. 4
      tests/test_tutorial/test_settings/test_app02.py
  46. 4
      tests/test_tutorial/test_settings/test_app03.py
  47. 3
      tests/test_union_body_discriminator.py
  48. 5
      tests/test_union_body_discriminator_annotated.py

5
tests/test_arbitrary_types.py

@ -5,8 +5,6 @@ from fastapi import FastAPI
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from .utils import needs_pydanticv2
@pytest.fixture(name="client")
def get_client():
@ -42,13 +40,11 @@ def get_client():
return client
@needs_pydanticv2
def test_get(client: TestClient):
response = client.get("/")
assert response.json() == {"custom_field": [1.0, 2.0, 3.0]}
@needs_pydanticv2
def test_typeadapter():
# This test is only to confirm that Pydantic alone is working as expected
from pydantic import (
@ -93,7 +89,6 @@ def test_typeadapter():
)
@needs_pydanticv2
def test_openapi_schema(client: TestClient):
response = client.get("openapi.json")
assert response.json() == snapshot(

8
tests/test_compat.py

@ -14,10 +14,9 @@ from fastapi.testclient import TestClient
from pydantic import BaseModel, ConfigDict
from pydantic.fields import FieldInfo
from .utils import needs_py310, needs_py_lt_314, needs_pydanticv2
from .utils import needs_py310, needs_py_lt_314
@needs_pydanticv2
def test_model_field_default_required():
from fastapi._compat import v2
@ -46,7 +45,6 @@ def test_is_model_field():
assert not _is_model_field(str)
@needs_pydanticv2
def test_get_model_config():
# For coverage in Pydantic v2
class Foo(BaseModel):
@ -75,7 +73,6 @@ def test_complex():
assert response2.json() == [1, 2]
@needs_pydanticv2
def test_propagates_pydantic2_model_config():
app = FastAPI()
@ -136,7 +133,6 @@ def test_is_uploadfile_sequence_annotation():
assert is_uploadfile_sequence_annotation(Union[list[str], list[UploadFile]])
@needs_pydanticv2
def test_serialize_sequence_value_with_optional_list():
"""Test that serialize_sequence_value handles optional lists correctly."""
from fastapi._compat import v2
@ -148,7 +144,6 @@ def test_serialize_sequence_value_with_optional_list():
assert isinstance(result, list)
@needs_pydanticv2
@needs_py310
def test_serialize_sequence_value_with_optional_list_pipe_union():
"""Test that serialize_sequence_value handles optional lists correctly (with new syntax)."""
@ -161,7 +156,6 @@ def test_serialize_sequence_value_with_optional_list_pipe_union():
assert isinstance(result, list)
@needs_pydanticv2
def test_serialize_sequence_value_with_none_first_in_union():
"""Test that serialize_sequence_value handles Union[None, List[...]] correctly."""
from fastapi._compat import v2

4
tests/test_computed_fields.py

@ -2,8 +2,6 @@ import pytest
from fastapi import FastAPI
from fastapi.testclient import TestClient
from .utils import needs_pydanticv2
@pytest.fixture(name="client")
def get_client(request):
@ -35,7 +33,6 @@ def get_client(request):
@pytest.mark.parametrize("client", [True, False], indirect=True)
@pytest.mark.parametrize("path", ["/", "/responses"])
@needs_pydanticv2
def test_get(client: TestClient, path: str):
response = client.get(path)
assert response.status_code == 200, response.text
@ -43,7 +40,6 @@ def test_get(client: TestClient, path: str):
@pytest.mark.parametrize("client", [True, False], indirect=True)
@needs_pydanticv2
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text

4
tests/test_datetime_custom_encoder.py

@ -4,10 +4,9 @@ from fastapi import FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel
from .utils import needs_pydanticv1, needs_pydanticv2
from .utils import needs_pydanticv1
@needs_pydanticv2
def test_pydanticv2():
from pydantic import field_serializer
@ -35,6 +34,7 @@ def test_pydanticv2():
@needs_pydanticv1
def test_pydanticv1():
from pydantic import v1
class ModelWithDatetimeField(v1.BaseModel):
dt_field: datetime

5
tests/test_filter_pydantic_sub_model_pv2.py

@ -6,8 +6,6 @@ from fastapi import Depends, FastAPI
from fastapi.exceptions import ResponseValidationError
from fastapi.testclient import TestClient
from .utils import needs_pydanticv2
@pytest.fixture(name="client")
def get_client():
@ -43,7 +41,6 @@ def get_client():
return client
@needs_pydanticv2
def test_filter_sub_model(client: TestClient):
response = client.get("/model/modelA")
assert response.status_code == 200, response.text
@ -54,7 +51,6 @@ def test_filter_sub_model(client: TestClient):
}
@needs_pydanticv2
def test_validator_is_cloned(client: TestClient):
with pytest.raises(ResponseValidationError) as err:
client.get("/model/modelX")
@ -79,7 +75,6 @@ def test_validator_is_cloned(client: TestClient):
]
@needs_pydanticv2
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text

4
tests/test_inherited_custom_class.py

@ -5,7 +5,7 @@ from fastapi import FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel
from .utils import needs_pydanticv1, needs_pydanticv2
from .utils import needs_pydanticv1
class MyUuid:
@ -26,7 +26,6 @@ class MyUuid:
raise TypeError("vars() argument must have __dict__ attribute")
@needs_pydanticv2
def test_pydanticv2():
from pydantic import field_serializer
@ -74,6 +73,7 @@ def test_pydanticv2():
@needs_pydanticv1
def test_pydanticv1():
from pydantic import v1
app = FastAPI()
@app.get("/fast_uuid")

8
tests/test_jsonable_encoder.py

@ -12,7 +12,7 @@ from fastapi._compat import Undefined
from fastapi.encoders import jsonable_encoder
from pydantic import BaseModel, Field, ValidationError
from .utils import needs_pydanticv1, needs_pydanticv2
from .utils import needs_pydanticv1
class Person:
@ -125,7 +125,6 @@ def test_encode_unsupported():
jsonable_encoder(unserializable)
@needs_pydanticv2
def test_encode_custom_json_encoders_model_pydanticv2():
from pydantic import field_serializer
@ -281,25 +280,21 @@ def test_encode_root():
assert jsonable_encoder(model) == "Foo"
@needs_pydanticv2
def test_decimal_encoder_float():
data = {"value": Decimal(1.23)}
assert jsonable_encoder(data) == {"value": 1.23}
@needs_pydanticv2
def test_decimal_encoder_int():
data = {"value": Decimal(2)}
assert jsonable_encoder(data) == {"value": 2}
@needs_pydanticv2
def test_decimal_encoder_nan():
data = {"value": Decimal("NaN")}
assert isnan(jsonable_encoder(data)["value"])
@needs_pydanticv2
def test_decimal_encoder_infinity():
data = {"value": Decimal("Infinity")}
assert isinf(jsonable_encoder(data)["value"])
@ -316,7 +311,6 @@ def test_encode_deque_encodes_child_models():
assert jsonable_encoder(dq)[0]["test"] == "test"
@needs_pydanticv2
def test_encode_pydantic_undefined():
data = {"value": Undefined}
assert jsonable_encoder(data) == {"value": None}

5
tests/test_openapi_separate_input_output_schemas.py

@ -5,8 +5,6 @@ from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from pydantic import BaseModel, computed_field
from .utils import needs_pydanticv2
class SubItem(BaseModel):
subname: str
@ -144,7 +142,6 @@ def test_read_items():
)
@needs_pydanticv2
def test_with_computed_field():
client = get_app_client()
client_no = get_app_client(separate_input_output_schemas=False)
@ -161,7 +158,6 @@ def test_with_computed_field():
)
@needs_pydanticv2
def test_openapi_schema():
client = get_app_client()
response = client.get("/openapi.json")
@ -442,7 +438,6 @@ def test_openapi_schema():
)
@needs_pydanticv2
def test_openapi_schema_no_separate():
client = get_app_client(separate_input_output_schemas=False)
response = client.get("/openapi.json")

4
tests/test_read_with_orm_mode.py

@ -4,10 +4,9 @@ from fastapi import FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel, ConfigDict
from .utils import needs_pydanticv1, needs_pydanticv2
from .utils import needs_pydanticv1
@needs_pydanticv2
def test_read_with_orm_mode() -> None:
class PersonBase(BaseModel):
name: str
@ -49,6 +48,7 @@ def test_read_with_orm_mode() -> None:
@needs_pydanticv1
def test_read_with_orm_mode_pv1() -> None:
from pydantic import v1
class PersonBase(v1.BaseModel):
name: str
lastname: str

11
tests/test_request_params/test_body/test_list.py

@ -6,8 +6,6 @@ from fastapi import Body, FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from tests.utils import needs_pydanticv2
from .utils import get_body_model_name
app = FastAPI()
@ -246,7 +244,6 @@ async def read_model_required_list_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/required-list-validation-alias", "/model-required-list-validation-alias"],
@ -269,7 +266,6 @@ def test_required_list_validation_alias_schema(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize("json", [None, {}])
@pytest.mark.parametrize(
"path",
@ -294,7 +290,6 @@ def test_required_list_validation_alias_missing(path: str, json: Union[dict, Non
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -319,7 +314,6 @@ def test_required_list_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -364,7 +358,6 @@ def read_model_required_list_alias_and_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -390,7 +383,6 @@ def test_required_list_alias_and_validation_alias_schema(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize("json", [None, {}])
@pytest.mark.parametrize(
"path",
@ -415,7 +407,6 @@ def test_required_list_alias_and_validation_alias_missing(path: str, json):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -442,7 +433,6 @@ def test_required_list_alias_and_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -467,7 +457,6 @@ def test_required_list_alias_and_validation_alias_by_alias(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

9
tests/test_request_params/test_body/test_optional_list.py

@ -6,8 +6,6 @@ from fastapi import Body, FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from tests.utils import needs_pydanticv2
from .utils import get_body_model_name
app = FastAPI()
@ -283,7 +281,6 @@ def read_model_optional_list_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-list-validation-alias", "/model-optional-list-validation-alias"],
@ -369,7 +366,6 @@ def test_optional_list_validation_alias_missing_empty_dict(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -384,7 +380,6 @@ def test_optional_list_validation_alias_by_name(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -432,7 +427,6 @@ def read_model_optional_list_alias_and_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -524,7 +518,6 @@ def test_optional_list_alias_and_validation_alias_missing_empty_dict(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -539,7 +532,6 @@ def test_optional_list_alias_and_validation_alias_by_name(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -554,7 +546,6 @@ def test_optional_list_alias_and_validation_alias_by_alias(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

15
tests/test_request_params/test_body/test_optional_str.py

@ -6,8 +6,6 @@ from fastapi import Body, FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from tests.utils import needs_pydanticv2
from .utils import get_body_model_name
app = FastAPI()
@ -268,7 +266,6 @@ def read_model_optional_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-validation-alias", "/model-optional-validation-alias"],
@ -300,7 +297,6 @@ def test_optional_validation_alias_schema(path: str):
)
@needs_pydanticv2
def test_optional_validation_alias_missing():
client = TestClient(app)
response = client.post("/optional-validation-alias")
@ -308,7 +304,6 @@ def test_optional_validation_alias_missing():
assert response.json() == {"p": None}
@needs_pydanticv2
def test_model_optional_validation_alias_missing():
client = TestClient(app)
response = client.post("/model-optional-validation-alias")
@ -338,7 +333,6 @@ def test_model_optional_validation_alias_missing():
)
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-validation-alias", "/model-optional-validation-alias"],
@ -350,7 +344,6 @@ def test_model_optional_validation_alias_missing_empty_dict(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -365,7 +358,6 @@ def test_optional_validation_alias_by_name(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -410,7 +402,6 @@ def read_model_optional_alias_and_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -445,7 +436,6 @@ def test_optional_alias_and_validation_alias_schema(path: str):
)
@needs_pydanticv2
def test_optional_alias_and_validation_alias_missing():
client = TestClient(app)
response = client.post("/optional-alias-and-validation-alias")
@ -453,7 +443,6 @@ def test_optional_alias_and_validation_alias_missing():
assert response.json() == {"p": None}
@needs_pydanticv2
def test_model_optional_alias_and_validation_alias_missing():
client = TestClient(app)
response = client.post("/model-optional-alias-and-validation-alias")
@ -483,7 +472,6 @@ def test_model_optional_alias_and_validation_alias_missing():
)
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -498,7 +486,6 @@ def test_model_optional_alias_and_validation_alias_missing_empty_dict(path: str)
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -513,7 +500,6 @@ def test_optional_alias_and_validation_alias_by_name(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -528,7 +514,6 @@ def test_optional_alias_and_validation_alias_by_alias(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_body/test_required_str.py

@ -6,8 +6,6 @@ from fastapi import Body, FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from tests.utils import needs_pydanticv2
from .utils import get_body_model_name
app = FastAPI()
@ -236,7 +234,6 @@ def read_model_required_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/required-validation-alias", "/model-required-validation-alias"],
@ -255,7 +252,6 @@ def test_required_validation_alias_schema(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize("json", [None, {}])
@pytest.mark.parametrize(
"path",
@ -282,7 +278,6 @@ def test_required_validation_alias_missing(
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -307,7 +302,6 @@ def test_required_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -353,7 +347,6 @@ def read_model_required_alias_and_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -375,7 +368,6 @@ def test_required_alias_and_validation_alias_schema(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize("json", [None, {}])
@pytest.mark.parametrize(
"path",
@ -402,7 +394,6 @@ def test_required_alias_and_validation_alias_missing(
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -430,7 +421,6 @@ def test_required_alias_and_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -455,7 +445,6 @@ def test_required_alias_and_validation_alias_by_alias(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_cookie/test_optional_str.py

@ -6,8 +6,6 @@ from fastapi import Cookie, FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from tests.utils import needs_pydanticv2
app = FastAPI()
# =====================================================================================
@ -189,7 +187,6 @@ def read_model_optional_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-validation-alias", "/model-optional-validation-alias"],
@ -208,7 +205,6 @@ def test_optional_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-validation-alias", "/model-optional-validation-alias"],
@ -220,7 +216,6 @@ def test_optional_validation_alias_missing(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -236,7 +231,6 @@ def test_optional_validation_alias_by_name(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -276,7 +270,6 @@ def read_model_optional_alias_and_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -298,7 +291,6 @@ def test_optional_alias_and_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -313,7 +305,6 @@ def test_optional_alias_and_validation_alias_missing(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -329,7 +320,6 @@ def test_optional_alias_and_validation_alias_by_name(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -345,7 +335,6 @@ def test_optional_alias_and_validation_alias_by_alias(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_cookie/test_required_str.py

@ -6,8 +6,6 @@ from fastapi import Cookie, FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from tests.utils import needs_pydanticv2
app = FastAPI()
# =====================================================================================
@ -231,7 +229,6 @@ def read_model_required_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/required-validation-alias", "/model-required-validation-alias"],
@ -247,7 +244,6 @@ def test_required_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -274,7 +270,6 @@ def test_required_validation_alias_missing(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -300,7 +295,6 @@ def test_required_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -339,7 +333,6 @@ def read_model_required_alias_and_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -358,7 +351,6 @@ def test_required_alias_and_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -385,7 +377,6 @@ def test_required_alias_and_validation_alias_missing(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -417,7 +408,6 @@ def test_required_alias_and_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -446,7 +436,6 @@ def test_required_alias_and_validation_alias_by_alias(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_file/test_list.py

@ -5,8 +5,6 @@ from dirty_equals import IsDict
from fastapi import FastAPI, File, UploadFile
from fastapi.testclient import TestClient
from tests.utils import needs_pydanticv2
from .utils import get_body_model_name
app = FastAPI()
@ -280,7 +278,6 @@ def read_list_uploadfile_validation_alias(
return {"file_size": [file.size for file in p]}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -322,7 +319,6 @@ def test_list_validation_alias_schema(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -349,7 +345,6 @@ def test_list_validation_alias_missing(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -374,7 +369,6 @@ def test_list_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -417,7 +411,6 @@ def read_list_uploadfile_alias_and_validation_alias(
return {"file_size": [file.size for file in p]}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -459,7 +452,6 @@ def test_list_alias_and_validation_alias_schema(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -486,7 +478,6 @@ def test_list_alias_and_validation_alias_missing(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -514,7 +505,6 @@ def test_list_alias_and_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -539,7 +529,6 @@ def test_list_alias_and_validation_alias_by_alias(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_file/test_optional.py

@ -5,8 +5,6 @@ from dirty_equals import IsDict
from fastapi import FastAPI, File, UploadFile
from fastapi.testclient import TestClient
from tests.utils import needs_pydanticv2
from .utils import get_body_model_name
app = FastAPI()
@ -204,7 +202,6 @@ def read_optional_uploadfile_validation_alias(
return {"file_size": p.size if p else None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -239,7 +236,6 @@ def test_optional_validation_alias_schema(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -254,7 +250,6 @@ def test_optional_validation_alias_missing(path: str):
assert response.json() == {"file_size": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -269,7 +264,6 @@ def test_optional_validation_alias_by_name(path: str):
assert response.json() == {"file_size": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -312,7 +306,6 @@ def read_optional_uploadfile_alias_and_validation_alias(
return {"file_size": p.size if p else None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -347,7 +340,6 @@ def test_optional_alias_and_validation_alias_schema(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -362,7 +354,6 @@ def test_optional_alias_and_validation_alias_missing(path: str):
assert response.json() == {"file_size": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -377,7 +368,6 @@ def test_optional_alias_and_validation_alias_by_name(path: str):
assert response.json() == {"file_size": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -392,7 +382,6 @@ def test_optional_alias_and_validation_alias_by_alias(path: str):
assert response.json() == {"file_size": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_file/test_optional_list.py

@ -5,8 +5,6 @@ from dirty_equals import IsDict
from fastapi import FastAPI, File, UploadFile
from fastapi.testclient import TestClient
from tests.utils import needs_pydanticv2
from .utils import get_body_model_name
app = FastAPI()
@ -217,7 +215,6 @@ def read_optional_list_uploadfile_validation_alias(
return {"file_size": [file.size for file in p] if p else None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -259,7 +256,6 @@ def test_optional_validation_alias_schema(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -274,7 +270,6 @@ def test_optional_validation_alias_missing(path: str):
assert response.json() == {"file_size": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -289,7 +284,6 @@ def test_optional_validation_alias_by_name(path: str):
assert response.json() == {"file_size": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -329,7 +323,6 @@ def read_optional_list_uploadfile_alias_and_validation_alias(
return {"file_size": [file.size for file in p] if p else None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -371,7 +364,6 @@ def test_optional_list_alias_and_validation_alias_schema(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -386,7 +378,6 @@ def test_optional_list_alias_and_validation_alias_missing(path: str):
assert response.json() == {"file_size": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -401,7 +392,6 @@ def test_optional_list_alias_and_validation_alias_by_name(path: str):
assert response.json() == {"file_size": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -416,7 +406,6 @@ def test_optional_list_alias_and_validation_alias_by_alias(path: str):
assert response.json() == {"file_size": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_file/test_required.py

@ -5,8 +5,6 @@ from dirty_equals import IsDict
from fastapi import FastAPI, File, UploadFile
from fastapi.testclient import TestClient
from tests.utils import needs_pydanticv2
from .utils import get_body_model_name
app = FastAPI()
@ -242,7 +240,6 @@ def read_required_uploadfile_validation_alias(
return {"file_size": p.size}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -268,7 +265,6 @@ def test_required_validation_alias_schema(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -295,7 +291,6 @@ def test_required_validation_alias_missing(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -320,7 +315,6 @@ def test_required_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -359,7 +353,6 @@ def read_required_uploadfile_alias_and_validation_alias(
return {"file_size": p.size}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -385,7 +378,6 @@ def test_required_alias_and_validation_alias_schema(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -412,7 +404,6 @@ def test_required_alias_and_validation_alias_missing(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -440,7 +431,6 @@ def test_required_alias_and_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -465,7 +455,6 @@ def test_required_alias_and_validation_alias_by_alias(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_form/test_list.py

@ -6,8 +6,6 @@ from fastapi import FastAPI, Form
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from tests.utils import needs_pydanticv2
from .utils import get_body_model_name
app = FastAPI()
@ -247,7 +245,6 @@ async def read_model_required_list_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/required-list-validation-alias", "/model-required-list-validation-alias"],
@ -270,7 +267,6 @@ def test_required_list_validation_alias_schema(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -297,7 +293,6 @@ def test_required_list_validation_alias_missing(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -322,7 +317,6 @@ def test_required_list_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/required-list-validation-alias", "/model-required-list-validation-alias"],
@ -363,7 +357,6 @@ def read_model_required_list_alias_and_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -389,7 +382,6 @@ def test_required_list_alias_and_validation_alias_schema(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -416,7 +408,6 @@ def test_required_list_alias_and_validation_alias_missing(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -446,7 +437,6 @@ def test_required_list_alias_and_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -470,7 +460,6 @@ def test_required_list_alias_and_validation_alias_by_alias(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_form/test_optional_list.py

@ -6,8 +6,6 @@ from fastapi import FastAPI, Form
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from tests.utils import needs_pydanticv2
from .utils import get_body_model_name
app = FastAPI()
@ -211,7 +209,6 @@ def read_model_optional_list_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-list-validation-alias", "/model-optional-list-validation-alias"],
@ -250,7 +247,6 @@ def test_optional_list_validation_alias_schema(path: str):
)
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-list-validation-alias", "/model-optional-list-validation-alias"],
@ -262,7 +258,6 @@ def test_optional_list_validation_alias_missing(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -277,7 +272,6 @@ def test_optional_list_validation_alias_by_name(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-list-validation-alias", "/model-optional-list-validation-alias"],
@ -321,7 +315,6 @@ def read_model_optional_list_alias_and_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -363,7 +356,6 @@ def test_optional_list_alias_and_validation_alias_schema(path: str):
)
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -378,7 +370,6 @@ def test_optional_list_alias_and_validation_alias_missing(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -393,7 +384,6 @@ def test_optional_list_alias_and_validation_alias_by_name(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -408,7 +398,6 @@ def test_optional_list_alias_and_validation_alias_by_alias(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_form/test_optional_str.py

@ -6,8 +6,6 @@ from fastapi import FastAPI, Form
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from tests.utils import needs_pydanticv2
from .utils import get_body_model_name
app = FastAPI()
@ -194,7 +192,6 @@ def read_model_optional_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-validation-alias", "/model-optional-validation-alias"],
@ -226,7 +223,6 @@ def test_optional_validation_alias_schema(path: str):
)
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-validation-alias", "/model-optional-validation-alias"],
@ -238,7 +234,6 @@ def test_optional_validation_alias_missing(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -253,7 +248,6 @@ def test_optional_validation_alias_by_name(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -298,7 +292,6 @@ def read_model_optional_alias_and_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -333,7 +326,6 @@ def test_optional_alias_and_validation_alias_schema(path: str):
)
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -348,7 +340,6 @@ def test_optional_alias_and_validation_alias_missing(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -363,7 +354,6 @@ def test_optional_alias_and_validation_alias_by_name(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -378,7 +368,6 @@ def test_optional_alias_and_validation_alias_by_alias(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_form/test_required_str.py

@ -6,8 +6,6 @@ from fastapi import FastAPI, Form
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from tests.utils import needs_pydanticv2
from .utils import get_body_model_name
app = FastAPI()
@ -232,7 +230,6 @@ def read_model_required_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/required-validation-alias", "/model-required-validation-alias"],
@ -251,7 +248,6 @@ def test_required_validation_alias_schema(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -278,7 +274,6 @@ def test_required_validation_alias_missing(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -303,7 +298,6 @@ def test_required_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -347,7 +341,6 @@ def read_model_required_alias_and_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -369,7 +362,6 @@ def test_required_alias_and_validation_alias_schema(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -396,7 +388,6 @@ def test_required_alias_and_validation_alias_missing(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -424,7 +415,6 @@ def test_required_alias_and_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -449,7 +439,6 @@ def test_required_alias_and_validation_alias_by_alias(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_header/test_list.py

@ -6,8 +6,6 @@ from fastapi import FastAPI, Header
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from tests.utils import needs_pydanticv2
app = FastAPI()
# =====================================================================================
@ -234,7 +232,6 @@ async def read_model_required_list_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/required-list-validation-alias", "/model-required-list-validation-alias"],
@ -254,7 +251,6 @@ def test_required_list_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -281,7 +277,6 @@ def test_required_list_validation_alias_missing(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -306,7 +301,6 @@ def test_required_list_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/required-list-validation-alias", "/model-required-list-validation-alias"],
@ -343,7 +337,6 @@ def read_model_required_list_alias_and_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -366,7 +359,6 @@ def test_required_list_alias_and_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -393,7 +385,6 @@ def test_required_list_alias_and_validation_alias_missing(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -423,7 +414,6 @@ def test_required_list_alias_and_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -450,7 +440,6 @@ def test_required_list_alias_and_validation_alias_by_alias(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_header/test_optional_list.py

@ -6,8 +6,6 @@ from fastapi import FastAPI, Header
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from tests.utils import needs_pydanticv2
app = FastAPI()
# =====================================================================================
@ -202,7 +200,6 @@ def read_model_optional_list_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-list-validation-alias", "/model-optional-list-validation-alias"],
@ -224,7 +221,6 @@ def test_optional_list_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-list-validation-alias", "/model-optional-list-validation-alias"],
@ -236,7 +232,6 @@ def test_optional_list_validation_alias_missing(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -251,7 +246,6 @@ def test_optional_list_validation_alias_by_name(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-list-validation-alias", "/model-optional-list-validation-alias"],
@ -291,7 +285,6 @@ def read_model_optional_list_alias_and_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -316,7 +309,6 @@ def test_optional_list_alias_and_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -331,7 +323,6 @@ def test_optional_list_alias_and_validation_alias_missing(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -346,7 +337,6 @@ def test_optional_list_alias_and_validation_alias_by_name(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -361,7 +351,6 @@ def test_optional_list_alias_and_validation_alias_by_alias(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_header/test_optional_str.py

@ -6,8 +6,6 @@ from fastapi import FastAPI, Header
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from tests.utils import needs_pydanticv2
app = FastAPI()
# =====================================================================================
@ -186,7 +184,6 @@ def read_model_optional_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-validation-alias", "/model-optional-validation-alias"],
@ -205,7 +202,6 @@ def test_optional_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-validation-alias", "/model-optional-validation-alias"],
@ -217,7 +213,6 @@ def test_optional_validation_alias_missing(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -232,7 +227,6 @@ def test_optional_validation_alias_by_name(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -271,7 +265,6 @@ def read_model_optional_alias_and_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -293,7 +286,6 @@ def test_optional_alias_and_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -308,7 +300,6 @@ def test_optional_alias_and_validation_alias_missing(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -323,7 +314,6 @@ def test_optional_alias_and_validation_alias_by_name(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -338,7 +328,6 @@ def test_optional_alias_and_validation_alias_by_alias(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_header/test_required_str.py

@ -6,8 +6,6 @@ from fastapi import FastAPI, Header
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from tests.utils import needs_pydanticv2
app = FastAPI()
# =====================================================================================
@ -225,7 +223,6 @@ def read_model_required_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/required-validation-alias", "/model-required-validation-alias"],
@ -241,7 +238,6 @@ def test_required_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -268,7 +264,6 @@ def test_required_validation_alias_missing(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -293,7 +288,6 @@ def test_required_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -331,7 +325,6 @@ def read_model_required_alias_and_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -350,7 +343,6 @@ def test_required_alias_and_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -377,7 +369,6 @@ def test_required_alias_and_validation_alias_missing(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -408,7 +399,6 @@ def test_required_alias_and_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -436,7 +426,6 @@ def test_required_alias_and_validation_alias_by_alias(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_query/test_list.py

@ -6,8 +6,6 @@ from fastapi import FastAPI, Query
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from tests.utils import needs_pydanticv2
app = FastAPI()
# =====================================================================================
@ -234,7 +232,6 @@ async def read_model_required_list_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/required-list-validation-alias", "/model-required-list-validation-alias"],
@ -254,7 +251,6 @@ def test_required_list_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -281,7 +277,6 @@ def test_required_list_validation_alias_missing(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -306,7 +301,6 @@ def test_required_list_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/required-list-validation-alias", "/model-required-list-validation-alias"],
@ -341,7 +335,6 @@ def read_model_required_list_alias_and_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -364,7 +357,6 @@ def test_required_list_alias_and_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -391,7 +383,6 @@ def test_required_list_alias_and_validation_alias_missing(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -426,7 +417,6 @@ def test_required_list_alias_and_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -453,7 +443,6 @@ def test_required_list_alias_and_validation_alias_by_alias(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_query/test_optional_list.py

@ -6,8 +6,6 @@ from fastapi import FastAPI, Query
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from tests.utils import needs_pydanticv2
app = FastAPI()
# =====================================================================================
@ -202,7 +200,6 @@ def read_model_optional_list_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-list-validation-alias", "/model-optional-list-validation-alias"],
@ -224,7 +221,6 @@ def test_optional_list_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-list-validation-alias", "/model-optional-list-validation-alias"],
@ -236,7 +232,6 @@ def test_optional_list_validation_alias_missing(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -251,7 +246,6 @@ def test_optional_list_validation_alias_by_name(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-list-validation-alias", "/model-optional-list-validation-alias"],
@ -289,7 +283,6 @@ def read_model_optional_list_alias_and_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -314,7 +307,6 @@ def test_optional_list_alias_and_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -329,7 +321,6 @@ def test_optional_list_alias_and_validation_alias_missing(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -344,7 +335,6 @@ def test_optional_list_alias_and_validation_alias_by_name(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -359,7 +349,6 @@ def test_optional_list_alias_and_validation_alias_by_alias(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_query/test_optional_str.py

@ -6,8 +6,6 @@ from fastapi import FastAPI, Query
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from tests.utils import needs_pydanticv2
app = FastAPI()
# =====================================================================================
@ -186,7 +184,6 @@ def read_model_optional_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-validation-alias", "/model-optional-validation-alias"],
@ -205,7 +202,6 @@ def test_optional_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/optional-validation-alias", "/model-optional-validation-alias"],
@ -217,7 +213,6 @@ def test_optional_validation_alias_missing(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -232,7 +227,6 @@ def test_optional_validation_alias_by_name(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -271,7 +265,6 @@ def read_model_optional_alias_and_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -293,7 +286,6 @@ def test_optional_alias_and_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -308,7 +300,6 @@ def test_optional_alias_and_validation_alias_missing(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -323,7 +314,6 @@ def test_optional_alias_and_validation_alias_by_name(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -338,7 +328,6 @@ def test_optional_alias_and_validation_alias_by_alias(path: str):
assert response.json() == {"p": None}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

11
tests/test_request_params/test_query/test_required_str.py

@ -6,8 +6,6 @@ from fastapi import FastAPI, Query
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field
from tests.utils import needs_pydanticv2
app = FastAPI()
# =====================================================================================
@ -228,7 +226,6 @@ def read_model_required_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
["/required-validation-alias", "/model-required-validation-alias"],
@ -244,7 +241,6 @@ def test_required_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -271,7 +267,6 @@ def test_required_validation_alias_missing(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -296,7 +291,6 @@ def test_required_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -334,7 +328,6 @@ def read_model_required_alias_and_validation_alias(
return {"p": p.p}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -353,7 +346,6 @@ def test_required_alias_and_validation_alias_schema(path: str):
]
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -380,7 +372,6 @@ def test_required_alias_and_validation_alias_missing(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -411,7 +402,6 @@ def test_required_alias_and_validation_alias_by_name(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[
@ -439,7 +429,6 @@ def test_required_alias_and_validation_alias_by_alias(path: str):
}
@needs_pydanticv2
@pytest.mark.parametrize(
"path",
[

4
tests/test_schema_compat_pydantic_v2.py

@ -4,7 +4,7 @@ from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from pydantic import BaseModel
from tests.utils import needs_py310, needs_pydanticv2
from tests.utils import needs_py310
@pytest.fixture(name="client")
@ -32,14 +32,12 @@ def get_client():
@needs_py310
@needs_pydanticv2
def test_get(client: TestClient):
response = client.get("/users")
assert response.json() == {"username": "alice", "role": "admin"}
@needs_py310
@needs_pydanticv2
def test_openapi_schema(client: TestClient):
response = client.get("openapi.json")
assert response.json() == snapshot(

4
tests/test_schema_ref_pydantic_v2.py

@ -6,8 +6,6 @@ from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from pydantic import BaseModel, ConfigDict, Field
from tests.utils import needs_pydanticv2
@pytest.fixture(name="client")
def get_client():
@ -25,13 +23,11 @@ def get_client():
return client
@needs_pydanticv2
def test_get(client: TestClient):
response = client.get("/")
assert response.json() == {"$ref": "some-ref"}
@needs_pydanticv2
def test_openapi_schema(client: TestClient):
response = client.get("openapi.json")
assert response.json() == snapshot(

3
tests/test_tutorial/test_body_updates/test_tutorial001.py

@ -3,7 +3,7 @@ import importlib
import pytest
from fastapi.testclient import TestClient
from ...utils import needs_py310, needs_pydanticv2
from ...utils import needs_py310
@pytest.fixture(
@ -45,7 +45,6 @@ def test_put(client: TestClient):
}
@needs_pydanticv2
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text

5
tests/test_tutorial/test_conditional_openapi/test_tutorial001.py

@ -2,8 +2,6 @@ import importlib
from fastapi.testclient import TestClient
from ...utils import needs_pydanticv2
def get_client() -> TestClient:
from docs_src.conditional_openapi import tutorial001_py39
@ -14,7 +12,6 @@ def get_client() -> TestClient:
return client
@needs_pydanticv2
def test_disable_openapi(monkeypatch):
monkeypatch.setenv("OPENAPI_URL", "")
# Load the client after setting the env var
@ -27,7 +24,6 @@ def test_disable_openapi(monkeypatch):
assert response.status_code == 404, response.text
@needs_pydanticv2
def test_root():
client = get_client()
response = client.get("/")
@ -35,7 +31,6 @@ def test_root():
assert response.json() == {"message": "Hello World"}
@needs_pydanticv2
def test_default_openapi():
client = get_client()
response = client.get("/docs")

5
tests/test_tutorial/test_dataclasses/test_tutorial003.py

@ -3,7 +3,7 @@ import importlib
import pytest
from fastapi.testclient import TestClient
from ...utils import needs_py310, needs_pydanticv2
from ...utils import needs_py310
@pytest.fixture(
@ -67,7 +67,6 @@ def test_get_authors(client: TestClient):
]
@needs_pydanticv2
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200
@ -201,5 +200,3 @@ def test_openapi_schema(client: TestClient):
}
},
}

3
tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial004.py

@ -3,7 +3,7 @@ import importlib
import pytest
from fastapi.testclient import TestClient
from ...utils import needs_py310, needs_pydanticv2
from ...utils import needs_py310
@pytest.fixture(
@ -35,7 +35,6 @@ def test_query_params_str_validations(client: TestClient):
}
@needs_pydanticv2
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text

6
tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial007.py

@ -3,8 +3,6 @@ import importlib
import pytest
from fastapi.testclient import TestClient
from ...utils import needs_pydanticv2
@pytest.fixture(
name="client",
@ -21,7 +19,6 @@ def get_client(request: pytest.FixtureRequest):
return client
@needs_pydanticv2
def test_post(client: TestClient):
yaml_data = """
name: Deadpoolio
@ -38,7 +35,6 @@ def test_post(client: TestClient):
}
@needs_pydanticv2
def test_post_broken_yaml(client: TestClient):
yaml_data = """
name: Deadpoolio
@ -52,7 +48,6 @@ def test_post_broken_yaml(client: TestClient):
assert response.json() == {"detail": "Invalid YAML"}
@needs_pydanticv2
def test_post_invalid(client: TestClient):
yaml_data = """
name: Deadpoolio
@ -77,7 +72,6 @@ def test_post_invalid(client: TestClient):
}
@needs_pydanticv2
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text

3
tests/test_tutorial/test_path_operation_configurations/test_tutorial005.py

@ -3,7 +3,7 @@ import importlib
import pytest
from fastapi.testclient import TestClient
from ...utils import needs_py310, needs_pydanticv2
from ...utils import needs_py310
@pytest.fixture(
@ -34,7 +34,6 @@ def test_query_params_str_validations(client: TestClient):
}
@needs_pydanticv2
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text

9
tests/test_tutorial/test_request_form_models/test_tutorial002.py

@ -3,8 +3,6 @@ import importlib
import pytest
from fastapi.testclient import TestClient
from ...utils import needs_pydanticv2
@pytest.fixture(
name="client",
@ -20,14 +18,12 @@ def get_client(request: pytest.FixtureRequest):
return client
@needs_pydanticv2
def test_post_body_form(client: TestClient):
response = client.post("/login/", data={"username": "Foo", "password": "secret"})
assert response.status_code == 200
assert response.json() == {"username": "Foo", "password": "secret"}
@needs_pydanticv2
def test_post_body_extra_form(client: TestClient):
response = client.post(
"/login/", data={"username": "Foo", "password": "secret", "extra": "extra"}
@ -45,7 +41,6 @@ def test_post_body_extra_form(client: TestClient):
}
@needs_pydanticv2
def test_post_body_form_no_password(client: TestClient):
response = client.post("/login/", data={"username": "Foo"})
assert response.status_code == 422
@ -61,7 +56,6 @@ def test_post_body_form_no_password(client: TestClient):
}
@needs_pydanticv2
def test_post_body_form_no_username(client: TestClient):
response = client.post("/login/", data={"password": "secret"})
assert response.status_code == 422
@ -77,7 +71,6 @@ def test_post_body_form_no_username(client: TestClient):
}
@needs_pydanticv2
def test_post_body_form_no_data(client: TestClient):
response = client.post("/login/")
assert response.status_code == 422
@ -99,7 +92,6 @@ def test_post_body_form_no_data(client: TestClient):
}
@needs_pydanticv2
def test_post_body_json(client: TestClient):
response = client.post("/login/", json={"username": "Foo", "password": "secret"})
assert response.status_code == 422, response.text
@ -121,7 +113,6 @@ def test_post_body_json(client: TestClient):
}
@needs_pydanticv2
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text

5
tests/test_tutorial/test_response_directly/test_tutorial001.py

@ -3,7 +3,7 @@ import importlib
import pytest
from fastapi.testclient import TestClient
from ...utils import needs_py310, needs_pydanticv2
from ...utils import needs_py310
@pytest.fixture(
@ -37,7 +37,6 @@ def test_path_operation(client: TestClient):
}
@needs_pydanticv2
def test_openapi_schema_pv2(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
@ -151,5 +150,3 @@ def test_openapi_schema_pv2(client: TestClient):
},
},
}

4
tests/test_tutorial/test_schema_extra_example/test_tutorial001.py

@ -3,7 +3,7 @@ import importlib
import pytest
from fastapi.testclient import TestClient
from ...utils import needs_py310, needs_pydanticv2
from ...utils import needs_py310
@pytest.fixture(
@ -20,7 +20,6 @@ def get_client(request: pytest.FixtureRequest):
return client
@needs_pydanticv2
def test_post_body_example(client: TestClient):
response = client.put(
"/items/5",
@ -34,7 +33,6 @@ def test_post_body_example(client: TestClient):
assert response.status_code == 200
@needs_pydanticv2
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text

3
tests/test_tutorial/test_separate_openapi_schemas/test_tutorial001.py

@ -3,7 +3,7 @@ import importlib
import pytest
from fastapi.testclient import TestClient
from ...utils import needs_py310, needs_pydanticv2
from ...utils import needs_py310
@pytest.fixture(
@ -38,7 +38,6 @@ def test_read_items(client: TestClient) -> None:
]
@needs_pydanticv2
def test_openapi_schema(client: TestClient) -> None:
response = client.get("/openapi.json")
assert response.status_code == 200, response.text

3
tests/test_tutorial/test_separate_openapi_schemas/test_tutorial002.py

@ -3,7 +3,7 @@ import importlib
import pytest
from fastapi.testclient import TestClient
from ...utils import needs_py310, needs_pydanticv2
from ...utils import needs_py310
@pytest.fixture(
@ -38,7 +38,6 @@ def test_read_items(client: TestClient) -> None:
]
@needs_pydanticv2
def test_openapi_schema(client: TestClient) -> None:
response = client.get("/openapi.json")
assert response.status_code == 200, response.text

4
tests/test_tutorial/test_settings/test_app02.py

@ -4,8 +4,6 @@ from types import ModuleType
import pytest
from pytest import MonkeyPatch
from ...utils import needs_pydanticv2
@pytest.fixture(
name="mod_path",
@ -31,7 +29,6 @@ def get_test_main_mod(mod_path: str) -> ModuleType:
return test_main_mod
@needs_pydanticv2
def test_settings(main_mod: ModuleType, monkeypatch: MonkeyPatch):
monkeypatch.setenv("ADMIN_EMAIL", "[email protected]")
settings = main_mod.get_settings()
@ -39,6 +36,5 @@ def test_settings(main_mod: ModuleType, monkeypatch: MonkeyPatch):
assert settings.items_per_user == 50
@needs_pydanticv2
def test_override_settings(test_main_mod: ModuleType):
test_main_mod.test_app()

4
tests/test_tutorial/test_settings/test_app03.py

@ -5,7 +5,7 @@ import pytest
from fastapi.testclient import TestClient
from pytest import MonkeyPatch
from ...utils import needs_pydanticv1, needs_pydanticv2
from ...utils import needs_pydanticv1
@pytest.fixture(
@ -26,7 +26,6 @@ def get_main_mod(mod_path: str) -> ModuleType:
return main_mod
@needs_pydanticv2
def test_settings(main_mod: ModuleType, monkeypatch: MonkeyPatch):
monkeypatch.setenv("ADMIN_EMAIL", "[email protected]")
settings = main_mod.get_settings()
@ -45,7 +44,6 @@ def test_settings_pv1(mod_path: str, monkeypatch: MonkeyPatch):
assert settings.items_per_user == 50
@needs_pydanticv2
def test_endpoint(main_mod: ModuleType, monkeypatch: MonkeyPatch):
monkeypatch.setenv("ADMIN_EMAIL", "[email protected]")
client = TestClient(main_mod.app)

3
tests/test_union_body_discriminator.py

@ -7,10 +7,7 @@ from inline_snapshot import snapshot
from pydantic import BaseModel, Field
from typing_extensions import Literal
from .utils import needs_pydanticv2
@needs_pydanticv2
def test_discriminator_pydantic_v2() -> None:
from pydantic import Tag

5
tests/test_union_body_discriminator_annotated.py

@ -8,8 +8,6 @@ from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from pydantic import BaseModel
from .utils import needs_pydanticv2
@pytest.fixture(name="client")
def client_fixture() -> TestClient:
@ -47,21 +45,18 @@ def client_fixture() -> TestClient:
return client
@needs_pydanticv2
def test_union_body_discriminator_assignment(client: TestClient) -> None:
response = client.post("/pet/assignment", json={"pet_type": "cat", "meows": 5})
assert response.status_code == 200, response.text
assert response.json() == {"pet_type": "cat", "meows": 5}
@needs_pydanticv2
def test_union_body_discriminator_annotated(client: TestClient) -> None:
response = client.post("/pet/annotated", json={"pet_type": "dog", "barks": 3.5})
assert response.status_code == 200, response.text
assert response.json() == {"pet_type": "dog", "barks": 3.5}
@needs_pydanticv2
def test_openapi_schema(client: TestClient) -> None:
response = client.get("/openapi.json")
assert response.status_code == 200, response.text

Loading…
Cancel
Save