]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
🔥 Remove Pydantic v1 specific test variants (#14611)
authorSebastián Ramírez <tiangolo@gmail.com>
Sat, 27 Dec 2025 18:19:10 +0000 (10:19 -0800)
committerGitHub <noreply@github.com>
Sat, 27 Dec 2025 18:19:10 +0000 (19:19 +0100)
104 files changed:
tests/test_additional_properties_bool.py
tests/test_additional_responses_custom_model_in_callback.py
tests/test_annotated.py
tests/test_application.py
tests/test_dependency_duplicates.py
tests/test_dependency_overrides.py
tests/test_extra_routes.py
tests/test_filter_pydantic_sub_model_pv2.py
tests/test_forms_single_model.py
tests/test_infer_param_optionality.py
tests/test_multi_body_errors.py
tests/test_multi_query_errors.py
tests/test_openapi_examples.py
tests/test_openapi_query_parameter_extension.py
tests/test_openapi_servers.py
tests/test_params_repr.py
tests/test_path.py
tests/test_query.py
tests/test_regex_deprecated_body.py
tests/test_regex_deprecated_params.py
tests/test_request_params/test_body/test_list.py
tests/test_request_params/test_body/test_optional_list.py
tests/test_request_params/test_body/test_optional_str.py
tests/test_request_params/test_body/test_required_str.py
tests/test_request_params/test_cookie/test_optional_str.py
tests/test_request_params/test_cookie/test_required_str.py
tests/test_request_params/test_file/test_list.py
tests/test_request_params/test_file/test_optional.py
tests/test_request_params/test_file/test_optional_list.py
tests/test_request_params/test_file/test_required.py
tests/test_request_params/test_form/test_list.py
tests/test_request_params/test_form/test_optional_list.py
tests/test_request_params/test_form/test_optional_str.py
tests/test_request_params/test_form/test_required_str.py
tests/test_request_params/test_header/test_list.py
tests/test_request_params/test_header/test_optional_list.py
tests/test_request_params/test_header/test_optional_str.py
tests/test_request_params/test_header/test_required_str.py
tests/test_request_params/test_query/test_list.py
tests/test_request_params/test_query/test_optional_list.py
tests/test_request_params/test_query/test_optional_str.py
tests/test_request_params/test_query/test_required_str.py
tests/test_schema_extra_examples.py
tests/test_security_oauth2.py
tests/test_security_oauth2_optional.py
tests/test_security_oauth2_optional_description.py
tests/test_sub_callbacks.py
tests/test_tuples.py
tests/test_tutorial/test_additional_responses/test_tutorial002.py
tests/test_tutorial/test_additional_responses/test_tutorial004.py
tests/test_tutorial/test_behind_a_proxy/test_tutorial003.py
tests/test_tutorial/test_behind_a_proxy/test_tutorial004.py
tests/test_tutorial/test_bigger_applications/test_main.py
tests/test_tutorial/test_body/test_tutorial001.py
tests/test_tutorial/test_body_fields/test_tutorial001.py
tests/test_tutorial/test_body_multiple_params/test_tutorial001.py
tests/test_tutorial/test_body_multiple_params/test_tutorial003.py
tests/test_tutorial/test_body_nested_models/test_tutorial009.py
tests/test_tutorial/test_cookie_param_models/test_tutorial001.py
tests/test_tutorial/test_cookie_param_models/test_tutorial002.py
tests/test_tutorial/test_cookie_params/test_tutorial001.py
tests/test_tutorial/test_custom_request_and_route/test_tutorial002.py
tests/test_tutorial/test_dataclasses/test_tutorial001.py
tests/test_tutorial/test_dataclasses/test_tutorial002.py
tests/test_tutorial/test_dependencies/test_tutorial006.py
tests/test_tutorial/test_dependencies/test_tutorial012.py
tests/test_tutorial/test_extra_data_types/test_tutorial001.py
tests/test_tutorial/test_extra_models/test_tutorial003.py
tests/test_tutorial/test_handling_errors/test_tutorial005.py
tests/test_tutorial/test_handling_errors/test_tutorial006.py
tests/test_tutorial/test_header_param_models/test_tutorial001.py
tests/test_tutorial/test_header_param_models/test_tutorial002.py
tests/test_tutorial/test_header_param_models/test_tutorial003.py
tests/test_tutorial/test_header_params/test_tutorial001.py
tests/test_tutorial/test_header_params/test_tutorial002.py
tests/test_tutorial/test_header_params/test_tutorial003.py
tests/test_tutorial/test_openapi_callbacks/test_tutorial001.py
tests/test_tutorial/test_path_params/test_tutorial005.py
tests/test_tutorial/test_query_param_models/test_tutorial001.py
tests/test_tutorial/test_query_param_models/test_tutorial002.py
tests/test_tutorial/test_query_params/test_tutorial005.py
tests/test_tutorial/test_query_params/test_tutorial006.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial010.py
tests/test_tutorial/test_query_params_str_validations/test_tutorial011.py
tests/test_tutorial/test_request_files/test_tutorial001.py
tests/test_tutorial/test_request_files/test_tutorial001_02.py
tests/test_tutorial/test_request_files/test_tutorial002.py
tests/test_tutorial/test_request_form_models/test_tutorial001.py
tests/test_tutorial/test_request_forms/test_tutorial001.py
tests/test_tutorial/test_request_forms_and_files/test_tutorial001.py
tests/test_tutorial/test_response_model/test_tutorial003.py
tests/test_tutorial/test_response_model/test_tutorial003_01.py
tests/test_tutorial/test_response_model/test_tutorial004.py
tests/test_tutorial/test_response_model/test_tutorial005.py
tests/test_tutorial/test_response_model/test_tutorial006.py
tests/test_tutorial/test_schema_extra_example/test_tutorial004.py
tests/test_tutorial/test_schema_extra_example/test_tutorial005.py
tests/test_tutorial/test_security/test_tutorial003.py
tests/test_tutorial/test_security/test_tutorial005.py
tests/test_tutorial/test_sql_databases/test_tutorial001.py
tests/test_tutorial/test_sql_databases/test_tutorial002.py
tests/test_union_body.py
tests/test_union_body_discriminator.py
tests/test_union_inherited_body.py

index 3756b7d7c999eb5d9313579af864b306160260ec..063297a3f29db4e2aba3ec96f335c3c753e50823 100644 (file)
@@ -1,6 +1,5 @@
 from typing import Union
 
-from dirty_equals import IsDict
 from fastapi import FastAPI
 from fastapi.testclient import TestClient
 from pydantic import BaseModel, ConfigDict
@@ -52,19 +51,13 @@ def test_openapi_schema():
                     "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": IsDict(
-                                    {
-                                        "anyOf": [
-                                            {"$ref": "#/components/schemas/Foo"},
-                                            {"type": "null"},
-                                        ],
-                                        "title": "Foo",
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {"$ref": "#/components/schemas/Foo"}
-                                )
+                                "schema": {
+                                    "anyOf": [
+                                        {"$ref": "#/components/schemas/Foo"},
+                                        {"type": "null"},
+                                    ],
+                                    "title": "Foo",
+                                }
                             }
                         }
                     },
index 2ad57545510a7109d0e520871d384dcc13d501a5..376d7714edfdd857728134b17c3ac19c4f4a60f0 100644 (file)
@@ -1,6 +1,6 @@
-from dirty_equals import IsDict
 from fastapi import APIRouter, FastAPI
 from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
 from pydantic import BaseModel, HttpUrl
 from starlette.responses import JSONResponse
 
@@ -32,121 +32,114 @@ client = TestClient(app)
 def test_openapi_schema():
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/": {
-                "post": {
-                    "summary": "Main Route",
-                    "operationId": "main_route__post",
-                    "parameters": [
-                        {
-                            "required": True,
-                            "schema": IsDict(
-                                {
-                                    "title": "Callback Url",
-                                    "minLength": 1,
-                                    "type": "string",
-                                    "format": "uri",
-                                }
-                            )
-                            # TODO: remove when deprecating Pydantic v1
-                            | IsDict(
-                                {
+    assert response.json() == snapshot(
+        {
+            "openapi": "3.1.0",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "paths": {
+                "/": {
+                    "post": {
+                        "summary": "Main Route",
+                        "operationId": "main_route__post",
+                        "parameters": [
+                            {
+                                "required": True,
+                                "schema": {
                                     "title": "Callback Url",
                                     "maxLength": 2083,
                                     "minLength": 1,
                                     "type": "string",
                                     "format": "uri",
-                                }
-                            ),
-                            "name": "callback_url",
-                            "in": "query",
-                        }
-                    ],
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                },
+                                "name": "callback_url",
+                                "in": "query",
+                            }
+                        ],
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {"application/json": {"schema": {}}},
+                            },
+                            "422": {
+                                "description": "Validation Error",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/HTTPValidationError"
+                                        }
                                     }
-                                }
+                                },
                             },
                         },
-                    },
-                    "callbacks": {
-                        "callback_route": {
-                            "{$callback_url}/callback/": {
-                                "get": {
-                                    "summary": "Callback Route",
-                                    "operationId": "callback_route__callback_url__callback__get",
-                                    "responses": {
-                                        "400": {
-                                            "content": {
-                                                "application/json": {
-                                                    "schema": {
-                                                        "$ref": "#/components/schemas/CustomModel"
+                        "callbacks": {
+                            "callback_route": {
+                                "{$callback_url}/callback/": {
+                                    "get": {
+                                        "summary": "Callback Route",
+                                        "operationId": "callback_route__callback_url__callback__get",
+                                        "responses": {
+                                            "400": {
+                                                "content": {
+                                                    "application/json": {
+                                                        "schema": {
+                                                            "$ref": "#/components/schemas/CustomModel"
+                                                        }
                                                     }
-                                                }
+                                                },
+                                                "description": "Bad Request",
                                             },
-                                            "description": "Bad Request",
-                                        },
-                                        "200": {
-                                            "description": "Successful Response",
-                                            "content": {
-                                                "application/json": {"schema": {}}
+                                            "200": {
+                                                "description": "Successful Response",
+                                                "content": {
+                                                    "application/json": {"schema": {}}
+                                                },
                                             },
                                         },
-                                    },
+                                    }
                                 }
                             }
-                        }
-                    },
+                        },
+                    }
                 }
-            }
-        },
-        "components": {
-            "schemas": {
-                "CustomModel": {
-                    "title": "CustomModel",
-                    "required": ["a"],
-                    "type": "object",
-                    "properties": {"a": {"title": "A", "type": "integer"}},
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
+            },
+            "components": {
+                "schemas": {
+                    "CustomModel": {
+                        "title": "CustomModel",
+                        "required": ["a"],
+                        "type": "object",
+                        "properties": {"a": {"title": "A", "type": "integer"}},
                     },
-                },
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                    "HTTPValidationError": {
+                        "title": "HTTPValidationError",
+                        "type": "object",
+                        "properties": {
+                            "detail": {
+                                "title": "Detail",
+                                "type": "array",
+                                "items": {
+                                    "$ref": "#/components/schemas/ValidationError"
+                                },
+                            }
+                        },
+                    },
+                    "ValidationError": {
+                        "title": "ValidationError",
+                        "required": ["loc", "msg", "type"],
+                        "type": "object",
+                        "properties": {
+                            "loc": {
+                                "title": "Location",
+                                "type": "array",
+                                "items": {
+                                    "anyOf": [{"type": "string"}, {"type": "integer"}]
+                                },
                             },
+                            "msg": {"title": "Message", "type": "string"},
+                            "type": {"title": "Error Type", "type": "string"},
                         },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
                     },
-                },
-            }
-        },
-    }
+                }
+            },
+        }
+    )
index a9e7c78c992b9e6b27a27a93ad56b2fde942de02..39f6f83b298486eb6c19e10fd9fc2c74d3f4b323 100644 (file)
@@ -1,7 +1,6 @@
 from typing import Annotated
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import APIRouter, FastAPI, Query
 from fastapi.testclient import TestClient
 
@@ -32,44 +31,23 @@ client = TestClient(app)
 
 foo_is_missing = {
     "detail": [
-        IsDict(
-            {
-                "loc": ["query", "foo"],
-                "msg": "Field required",
-                "type": "missing",
-                "input": None,
-            }
-        )
-        # TODO: remove when deprecating Pydantic v1
-        | IsDict(
-            {
-                "loc": ["query", "foo"],
-                "msg": "field required",
-                "type": "value_error.missing",
-            }
-        )
+        {
+            "loc": ["query", "foo"],
+            "msg": "Field required",
+            "type": "missing",
+            "input": None,
+        }
     ]
 }
 foo_is_short = {
     "detail": [
-        IsDict(
-            {
-                "ctx": {"min_length": 1},
-                "loc": ["query", "foo"],
-                "msg": "String should have at least 1 character",
-                "type": "string_too_short",
-                "input": "",
-            }
-        )
-        # TODO: remove when deprecating Pydantic v1
-        | IsDict(
-            {
-                "ctx": {"limit_value": 1},
-                "loc": ["query", "foo"],
-                "msg": "ensure this value has at least 1 characters",
-                "type": "value_error.any_str.min_length",
-            }
-        )
+        {
+            "ctx": {"min_length": 1},
+            "loc": ["query", "foo"],
+            "msg": "String should have at least 1 character",
+            "type": "string_too_short",
+            "input": "",
+        }
     ]
 }
 
index 8f1b0a18d37728f1651f328a72a6c09966d464af..001586ff7898df543634a150a60d20a70f847ecd 100644 (file)
@@ -1,5 +1,4 @@
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from .main import app
@@ -274,14 +273,10 @@ def test_openapi_schema():
                             "name": "item_id",
                             "in": "path",
                             "required": True,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Item Id",
-                                }
-                            )
-                            # TODO: remove when deprecating Pydantic v1
-                            | IsDict({"title": "Item Id", "type": "string"}),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "Item Id",
+                            },
                         }
                     ],
                 }
@@ -984,14 +979,10 @@ def test_openapi_schema():
                             "name": "query",
                             "in": "query",
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "integer"}, {"type": "null"}],
-                                    "title": "Query",
-                                }
-                            )
-                            # TODO: remove when deprecating Pydantic v1
-                            | IsDict({"title": "Query", "type": "integer"}),
+                            "schema": {
+                                "anyOf": [{"type": "integer"}, {"type": "null"}],
+                                "title": "Query",
+                            },
                         }
                     ],
                 }
index 7c6717e2aa5fce23dee21a8a0f6c5daeb2ef9d0f..a8658e03bb34237623a8cea5c20664c1effc0852 100644 (file)
@@ -1,4 +1,3 @@
-from dirty_equals import IsDict
 from fastapi import Depends, FastAPI
 from fastapi.testclient import TestClient
 from pydantic import BaseModel
@@ -46,29 +45,16 @@ async def no_duplicates_sub(
 def test_no_duplicates_invalid():
     response = client.post("/no-duplicates", json={"item": {"data": "myitem"}})
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "item2"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "item2"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "item2"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_no_duplicates():
index 154937fa0b9b6c0b1832c44fb9a742ab727452dc..e25db624d8fdcf0d19823e33a6f2327500e8d27e 100644 (file)
@@ -1,7 +1,6 @@
 from typing import Optional
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import APIRouter, Depends, FastAPI
 from fastapi.testclient import TestClient
 
@@ -54,29 +53,16 @@ async def overrider_dependency_with_sub(msg: dict = Depends(overrider_sub_depend
 def test_main_depends():
     response = client.get("/main-depends/")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "q"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "q"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "q"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_main_depends_q_foo():
@@ -100,29 +86,16 @@ def test_main_depends_q_foo_skip_100_limit_200():
 def test_decorator_depends():
     response = client.get("/decorator-depends/")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "q"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "q"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "q"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_decorator_depends_q_foo():
@@ -140,29 +113,16 @@ def test_decorator_depends_q_foo_skip_100_limit_200():
 def test_router_depends():
     response = client.get("/router-depends/")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "q"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "q"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "q"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_router_depends_q_foo():
@@ -186,29 +146,16 @@ def test_router_depends_q_foo_skip_100_limit_200():
 def test_router_decorator_depends():
     response = client.get("/router-decorator-depends/")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "q"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "q"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "q"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_router_decorator_depends_q_foo():
@@ -272,29 +219,17 @@ def test_override_with_sub_main_depends():
     app.dependency_overrides[common_parameters] = overrider_dependency_with_sub
     response = client.get("/main-depends/")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "k"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "k"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "k"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
+
     app.dependency_overrides = {}
 
 
@@ -302,29 +237,17 @@ def test_override_with_sub__main_depends_q_foo():
     app.dependency_overrides[common_parameters] = overrider_dependency_with_sub
     response = client.get("/main-depends/?q=foo")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "k"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "k"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "k"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
+
     app.dependency_overrides = {}
 
 
@@ -340,29 +263,17 @@ def test_override_with_sub_decorator_depends():
     app.dependency_overrides[common_parameters] = overrider_dependency_with_sub
     response = client.get("/decorator-depends/")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "k"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "k"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "k"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
+
     app.dependency_overrides = {}
 
 
@@ -370,29 +281,17 @@ def test_override_with_sub_decorator_depends_q_foo():
     app.dependency_overrides[common_parameters] = overrider_dependency_with_sub
     response = client.get("/decorator-depends/?q=foo")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "k"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "k"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "k"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
+
     app.dependency_overrides = {}
 
 
@@ -408,29 +307,17 @@ def test_override_with_sub_router_depends():
     app.dependency_overrides[common_parameters] = overrider_dependency_with_sub
     response = client.get("/router-depends/")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "k"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "k"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "k"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
+
     app.dependency_overrides = {}
 
 
@@ -438,29 +325,17 @@ def test_override_with_sub_router_depends_q_foo():
     app.dependency_overrides[common_parameters] = overrider_dependency_with_sub
     response = client.get("/router-depends/?q=foo")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "k"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "k"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "k"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
+
     app.dependency_overrides = {}
 
 
@@ -476,29 +351,17 @@ def test_override_with_sub_router_decorator_depends():
     app.dependency_overrides[common_parameters] = overrider_dependency_with_sub
     response = client.get("/router-decorator-depends/")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "k"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "k"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "k"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
+
     app.dependency_overrides = {}
 
 
@@ -506,29 +369,17 @@ def test_override_with_sub_router_decorator_depends_q_foo():
     app.dependency_overrides[common_parameters] = overrider_dependency_with_sub
     response = client.get("/router-decorator-depends/?q=foo")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "k"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "k"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "k"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
+
     app.dependency_overrides = {}
 
 
index bd16fe9254cc341e0f0907676a0033694abc33e4..45734ec28a3a92e4706f85dbc5f8536eb72703a4 100644 (file)
@@ -1,6 +1,5 @@
 from typing import Optional
 
-from dirty_equals import IsDict
 from fastapi import FastAPI
 from fastapi.responses import JSONResponse
 from fastapi.testclient import TestClient
@@ -328,14 +327,10 @@ def test_openapi_schema():
                     "type": "object",
                     "properties": {
                         "name": {"title": "Name", "type": "string"},
-                        "price": IsDict(
-                            {
-                                "title": "Price",
-                                "anyOf": [{"type": "number"}, {"type": "null"}],
-                            }
-                        )
-                        # TODO: remove when deprecating Pydantic v1
-                        | IsDict({"title": "Price", "type": "number"}),
+                        "price": {
+                            "title": "Price",
+                            "anyOf": [{"type": "number"}, {"type": "null"}],
+                        },
                     },
                 },
                 "ValidationError": {
index d70f5304350948ef9d9419e2f6d518dd8ef1c551..fc5876410daded02b682af63505b83309635eca9 100644 (file)
@@ -1,7 +1,7 @@
 from typing import Optional
 
 import pytest
-from dirty_equals import HasRepr, IsDict, IsOneOf
+from dirty_equals import HasRepr
 from fastapi import Depends, FastAPI
 from fastapi.exceptions import ResponseValidationError
 from fastapi.testclient import TestClient
@@ -63,23 +63,13 @@ def test_validator_is_cloned(client: TestClient):
     with pytest.raises(ResponseValidationError) as err:
         client.get("/model/modelX")
     assert err.value.errors() == [
-        IsDict(
-            {
-                "type": "value_error",
-                "loc": ("response", "name"),
-                "msg": "Value error, name must end in A",
-                "input": "modelX",
-                "ctx": {"error": HasRepr("ValueError('name must end in A')")},
-            }
-        )
-        | IsDict(
-            # TODO remove when deprecating Pydantic v1
-            {
-                "loc": ("response", "name"),
-                "msg": "name must end in A",
-                "type": "value_error",
-            }
-        )
+        {
+            "type": "value_error",
+            "loc": ("response", "name"),
+            "msg": "Value error, name must end in A",
+            "input": "modelX",
+            "ctx": {"error": HasRepr("ValueError('name must end in A')")},
+        }
     ]
 
 
@@ -145,23 +135,14 @@ def test_openapi_schema(client: TestClient):
                     },
                     "ModelA": {
                         "title": "ModelA",
-                        "required": IsOneOf(
-                            ["name", "description", "foo"],
-                            # TODO remove when deprecating Pydantic v1
-                            ["name", "foo"],
-                        ),
+                        "required": ["name", "foo"],
                         "type": "object",
                         "properties": {
                             "name": {"title": "Name", "type": "string"},
-                            "description": IsDict(
-                                {
-                                    "title": "Description",
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                }
-                            )
-                            |
-                            # TODO remove when deprecating Pydantic v1
-                            IsDict({"title": "Description", "type": "string"}),
+                            "description": {
+                                "title": "Description",
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                            },
                             "foo": {"$ref": "#/components/schemas/ModelB"},
                             "tags": {
                                 "additionalProperties": {"type": "string"},
index c401cc937400f8f29e8b86f23386aa7d347ae177..7d03d29572d1b2f3988a50212a85b0c445d84192 100644 (file)
@@ -1,6 +1,5 @@
 from typing import Annotated, Optional
 
-from dirty_equals import IsDict
 from fastapi import FastAPI, Form
 from fastapi.testclient import TestClient
 from pydantic import BaseModel, Field
@@ -79,68 +78,37 @@ def test_invalid_data():
         },
     )
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["body", "age"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "seventy",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "age"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["body", "age"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "seventy",
+            }
+        ]
+    }
 
 
 def test_no_data():
     response = client.post("/form/")
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "username"],
-                    "msg": "Field required",
-                    "input": {"tags": ["foo", "bar"], "with": "nothing"},
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "lastname"],
-                    "msg": "Field required",
-                    "input": {"tags": ["foo", "bar"], "with": "nothing"},
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "username"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "lastname"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "username"],
+                "msg": "Field required",
+                "input": {"tags": ["foo", "bar"], "with": "nothing"},
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "lastname"],
+                "msg": "Field required",
+                "input": {"tags": ["foo", "bar"], "with": "nothing"},
+            },
+        ]
+    }
 
 
 def test_extra_param_single():
index e3d57bb428bf2e789040fdda1c039ba62cff1b1b..147018996e9dd322772dbe4a94d6044af6af41dc 100644 (file)
@@ -1,6 +1,5 @@
 from typing import Optional
 
-from dirty_equals import IsDict
 from fastapi import APIRouter, FastAPI
 from fastapi.testclient import TestClient
 
@@ -163,16 +162,10 @@ def test_openapi_schema():
                             "required": False,
                             "name": "user_id",
                             "in": "query",
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "User Id",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "User Id", "type": "string"}
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "User Id",
+                            },
                         }
                     ],
                     "responses": {
@@ -208,16 +201,10 @@ def test_openapi_schema():
                             "required": False,
                             "name": "user_id",
                             "in": "query",
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "User Id",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "User Id", "type": "string"}
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "User Id",
+                            },
                         },
                     ],
                     "responses": {
@@ -247,16 +234,10 @@ def test_openapi_schema():
                             "required": True,
                             "name": "user_id",
                             "in": "path",
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "User Id",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "User Id", "type": "string"}
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "User Id",
+                            },
                         }
                     ],
                     "responses": {
@@ -292,16 +273,10 @@ def test_openapi_schema():
                             "required": True,
                             "name": "user_id",
                             "in": "path",
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "User Id",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "User Id", "type": "string"}
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "User Id",
+                            },
                         },
                     ],
                     "responses": {
index 6ea405fe700fbd9097c7d1a4366511462e368c36..4418c77cb0f8ce72c4ab3e963f687fd69911e9a6 100644 (file)
@@ -1,8 +1,9 @@
 from decimal import Decimal
 
-from dirty_equals import IsDict, IsOneOf
+from dirty_equals import IsOneOf
 from fastapi import FastAPI
 from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
 from pydantic import BaseModel, condecimal
 
 app = FastAPI()
@@ -24,109 +25,65 @@ client = TestClient(app)
 def test_put_correct_body():
     response = client.post("/items/", json=[{"name": "Foo", "age": 5}])
     assert response.status_code == 200, response.text
-    assert response.json() == {
-        "item": [
-            {
-                "name": "Foo",
-                "age": IsOneOf(
-                    5,
-                    # TODO: remove when deprecating Pydantic v1
-                    "5",
-                ),
-            }
-        ]
-    }
-
-
-def test_jsonable_encoder_requiring_error():
-    response = client.post("/items/", json=[{"name": "Foo", "age": -1.0}])
-    assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "greater_than",
-                    "loc": ["body", 0, "age"],
-                    "msg": "Input should be greater than 0",
-                    "input": -1.0,
-                    "ctx": {"gt": 0},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
+    assert response.json() == snapshot(
         {
-            "detail": [
+            "item": [
                 {
-                    "ctx": {"limit_value": 0.0},
-                    "loc": ["body", 0, "age"],
-                    "msg": "ensure this value is greater than 0",
-                    "type": "value_error.number.not_gt",
+                    "name": "Foo",
+                    "age": "5",
                 }
             ]
         }
     )
 
 
+def test_jsonable_encoder_requiring_error():
+    response = client.post("/items/", json=[{"name": "Foo", "age": -1.0}])
+    assert response.status_code == 422, response.text
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "greater_than",
+                "loc": ["body", 0, "age"],
+                "msg": "Input should be greater than 0",
+                "input": -1.0,
+                "ctx": {"gt": 0},
+            }
+        ]
+    }
+
+
 def test_put_incorrect_body_multiple():
     response = client.post("/items/", json=[{"age": "five"}, {"age": "six"}])
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", 0, "name"],
-                    "msg": "Field required",
-                    "input": {"age": "five"},
-                },
-                {
-                    "type": "decimal_parsing",
-                    "loc": ["body", 0, "age"],
-                    "msg": "Input should be a valid decimal",
-                    "input": "five",
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", 1, "name"],
-                    "msg": "Field required",
-                    "input": {"age": "six"},
-                },
-                {
-                    "type": "decimal_parsing",
-                    "loc": ["body", 1, "age"],
-                    "msg": "Input should be a valid decimal",
-                    "input": "six",
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", 0, "name"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", 0, "age"],
-                    "msg": "value is not a valid decimal",
-                    "type": "type_error.decimal",
-                },
-                {
-                    "loc": ["body", 1, "name"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", 1, "age"],
-                    "msg": "value is not a valid decimal",
-                    "type": "type_error.decimal",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", 0, "name"],
+                "msg": "Field required",
+                "input": {"age": "five"},
+            },
+            {
+                "type": "decimal_parsing",
+                "loc": ["body", 0, "age"],
+                "msg": "Input should be a valid decimal",
+                "input": "five",
+            },
+            {
+                "type": "missing",
+                "loc": ["body", 1, "name"],
+                "msg": "Field required",
+                "input": {"age": "six"},
+            },
+            {
+                "type": "decimal_parsing",
+                "loc": ["body", 1, "age"],
+                "msg": "Input should be a valid decimal",
+                "input": "six",
+            },
+        ]
+    }
 
 
 def test_openapi_schema():
@@ -179,31 +136,21 @@ def test_openapi_schema():
                     "type": "object",
                     "properties": {
                         "name": {"title": "Name", "type": "string"},
-                        "age": IsDict(
-                            {
-                                "title": "Age",
-                                "anyOf": [
-                                    {"exclusiveMinimum": 0.0, "type": "number"},
-                                    IsOneOf(
-                                        # pydantic < 2.12.0
-                                        {"type": "string"},
-                                        # pydantic >= 2.12.0
-                                        {
-                                            "type": "string",
-                                            "pattern": r"^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$",
-                                        },
-                                    ),
-                                ],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {
-                                "title": "Age",
-                                "exclusiveMinimum": 0.0,
-                                "type": "number",
-                            }
-                        ),
+                        "age": {
+                            "title": "Age",
+                            "anyOf": [
+                                {"exclusiveMinimum": 0.0, "type": "number"},
+                                IsOneOf(
+                                    # pydantic < 2.12.0
+                                    {"type": "string"},
+                                    # pydantic >= 2.12.0
+                                    {
+                                        "type": "string",
+                                        "pattern": r"^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$",
+                                    },
+                                ),
+                            ],
+                        },
                     },
                 },
                 "ValidationError": {
index 7387a81ddf1f0706555903b33464a08cf7f8e1d1..5df51ba185165074f311b4f0f4a158ed1f8bc9c3 100644 (file)
@@ -1,4 +1,3 @@
-from dirty_equals import IsDict
 from fastapi import FastAPI, Query
 from fastapi.testclient import TestClient
 
@@ -22,40 +21,22 @@ def test_multi_query():
 def test_multi_query_incorrect():
     response = client.get("/items/?q=five&q=six")
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["query", "q", 0],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "five",
-                },
-                {
-                    "type": "int_parsing",
-                    "loc": ["query", "q", 1],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "six",
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "q", 0],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                },
-                {
-                    "loc": ["query", "q", 1],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["query", "q", 0],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "five",
+            },
+            {
+                "type": "int_parsing",
+                "loc": ["query", "q", 1],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "six",
+            },
+        ]
+    }
 
 
 def test_openapi_schema():
index b3f83ae237ff84fd8841116a56d68a59d00018ab..bd0d55452eda05729a543a7c24945351c131ba7b 100644 (file)
@@ -1,6 +1,5 @@
 from typing import Union
 
-from dirty_equals import IsDict
 from fastapi import Body, Cookie, FastAPI, Header, Path, Query
 from fastapi.testclient import TestClient
 from pydantic import BaseModel
@@ -155,26 +154,12 @@ def test_openapi_schema():
                     "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": IsDict(
-                                    {
-                                        "$ref": "#/components/schemas/Item",
-                                        "examples": [
-                                            {"data": "Data in Body examples, example1"}
-                                        ],
-                                    }
-                                )
-                                | IsDict(
-                                    {
-                                        # TODO: remove when deprecating Pydantic v1
-                                        "allOf": [
-                                            {"$ref": "#/components/schemas/Item"}
-                                        ],
-                                        "title": "Item",
-                                        "examples": [
-                                            {"data": "Data in Body examples, example1"}
-                                        ],
-                                    }
-                                ),
+                                "schema": {
+                                    "$ref": "#/components/schemas/Item",
+                                    "examples": [
+                                        {"data": "Data in Body examples, example1"}
+                                    ],
+                                },
                                 "examples": {
                                     "Example One": {
                                         "summary": "Example One Summary",
@@ -265,27 +250,14 @@ def test_openapi_schema():
                             "name": "data",
                             "in": "query",
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "examples": [
-                                        "json_schema_query1",
-                                        "json_schema_query2",
-                                    ],
-                                    "title": "Data",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {
-                                    "examples": [
-                                        "json_schema_query1",
-                                        "json_schema_query2",
-                                    ],
-                                    "type": "string",
-                                    "title": "Data",
-                                }
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "examples": [
+                                    "json_schema_query1",
+                                    "json_schema_query2",
+                                ],
+                                "title": "Data",
+                            },
                             "examples": {
                                 "Query One": {
                                     "summary": "Query One Summary",
@@ -323,27 +295,14 @@ def test_openapi_schema():
                             "name": "data",
                             "in": "header",
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "examples": [
-                                        "json_schema_header1",
-                                        "json_schema_header2",
-                                    ],
-                                    "title": "Data",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {
-                                    "type": "string",
-                                    "examples": [
-                                        "json_schema_header1",
-                                        "json_schema_header2",
-                                    ],
-                                    "title": "Data",
-                                }
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "examples": [
+                                    "json_schema_header1",
+                                    "json_schema_header2",
+                                ],
+                                "title": "Data",
+                            },
                             "examples": {
                                 "Header One": {
                                     "summary": "Header One Summary",
@@ -381,27 +340,14 @@ def test_openapi_schema():
                             "name": "data",
                             "in": "cookie",
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "examples": [
-                                        "json_schema_cookie1",
-                                        "json_schema_cookie2",
-                                    ],
-                                    "title": "Data",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {
-                                    "type": "string",
-                                    "examples": [
-                                        "json_schema_cookie1",
-                                        "json_schema_cookie2",
-                                    ],
-                                    "title": "Data",
-                                }
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "examples": [
+                                    "json_schema_cookie1",
+                                    "json_schema_cookie2",
+                                ],
+                                "title": "Data",
+                            },
                             "examples": {
                                 "Cookie One": {
                                     "summary": "Cookie One Summary",
index dc7147c712463b4736964d91669b743bea2f8939..084cb695d477c2dd11276c2eacf590dc35ebdeb5 100644 (file)
@@ -1,6 +1,5 @@
 from typing import Optional
 
-from dirty_equals import IsDict
 from fastapi import FastAPI
 from fastapi.testclient import TestClient
 
@@ -53,21 +52,11 @@ def test_openapi():
                     "parameters": [
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "integer"}, {"type": "null"}],
-                                    "default": 50,
-                                    "title": "Standard Query Param",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {
-                                    "title": "Standard Query Param",
-                                    "type": "integer",
-                                    "default": 50,
-                                }
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "integer"}, {"type": "null"}],
+                                "default": 50,
+                                "title": "Standard Query Param",
+                            },
                             "name": "standard_query_param",
                             "in": "query",
                         },
index 8697c8438b7c7c11763526af870e59a4c4788f68..33079e4b1dbb82bcac73714598b6522529b5dd43 100644 (file)
@@ -1,6 +1,6 @@
-from dirty_equals import IsOneOf
 from fastapi import FastAPI
 from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
 
 app = FastAPI(
     servers=[
@@ -30,39 +30,31 @@ def test_app():
 def test_openapi_schema():
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "servers": [
-            {"url": "/", "description": "Default, relative server"},
-            {
-                "url": IsOneOf(
-                    "http://staging.localhost.tiangolo.com:8000/",
-                    # TODO: remove when deprecating Pydantic v1
-                    "http://staging.localhost.tiangolo.com:8000",
-                ),
-                "description": "Staging but actually localhost still",
-            },
-            {
-                "url": IsOneOf(
-                    "https://prod.example.com/",
-                    # TODO: remove when deprecating Pydantic v1
-                    "https://prod.example.com",
-                )
-            },
-        ],
-        "paths": {
-            "/foo": {
-                "get": {
-                    "summary": "Foo",
-                    "operationId": "foo_foo_get",
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        }
-                    },
+    assert response.json() == snapshot(
+        {
+            "openapi": "3.1.0",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "servers": [
+                {"url": "/", "description": "Default, relative server"},
+                {
+                    "url": "http://staging.localhost.tiangolo.com:8000",
+                    "description": "Staging but actually localhost still",
+                },
+                {"url": "https://prod.example.com"},
+            ],
+            "paths": {
+                "/foo": {
+                    "get": {
+                        "summary": "Foo",
+                        "operationId": "foo_foo_get",
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {"application/json": {"schema": {}}},
+                            }
+                        },
+                    }
                 }
-            }
-        },
-    }
+            },
+        }
+    )
index 19c2e8d696de98ca6d22a4081a0a49fd4e9d7276..670e4f5ddf142b829c00b628b7d313326fce5b09 100644 (file)
@@ -1,6 +1,5 @@
 from typing import Any
 
-from dirty_equals import IsOneOf
 from fastapi.params import Body, Cookie, Header, Param, Path, Query
 
 test_data: list[Any] = ["teststr", None, ..., 1, []]
@@ -19,11 +18,7 @@ def test_param_repr_none():
 
 
 def test_param_repr_ellipsis():
-    assert repr(Param(...)) == IsOneOf(
-        "Param(PydanticUndefined)",
-        # TODO: remove when deprecating Pydantic v1
-        "Param(Ellipsis)",
-    )
+    assert repr(Param(...)) == "Param(PydanticUndefined)"
 
 
 def test_param_repr_number():
@@ -35,16 +30,8 @@ def test_param_repr_list():
 
 
 def test_path_repr():
-    assert repr(Path()) == IsOneOf(
-        "Path(PydanticUndefined)",
-        # TODO: remove when deprecating Pydantic v1
-        "Path(Ellipsis)",
-    )
-    assert repr(Path(...)) == IsOneOf(
-        "Path(PydanticUndefined)",
-        # TODO: remove when deprecating Pydantic v1
-        "Path(Ellipsis)",
-    )
+    assert repr(Path()) == "Path(PydanticUndefined)"
+    assert repr(Path(...)) == "Path(PydanticUndefined)"
 
 
 def test_query_repr_str():
@@ -56,11 +43,7 @@ def test_query_repr_none():
 
 
 def test_query_repr_ellipsis():
-    assert repr(Query(...)) == IsOneOf(
-        "Query(PydanticUndefined)",
-        # TODO: remove when deprecating Pydantic v1
-        "Query(Ellipsis)",
-    )
+    assert repr(Query(...)) == "Query(PydanticUndefined)"
 
 
 def test_query_repr_number():
@@ -80,11 +63,7 @@ def test_header_repr_none():
 
 
 def test_header_repr_ellipsis():
-    assert repr(Header(...)) == IsOneOf(
-        "Header(PydanticUndefined)",
-        # TODO: remove when deprecating Pydantic v1
-        "Header(Ellipsis)",
-    )
+    assert repr(Header(...)) == "Header(PydanticUndefined)"
 
 
 def test_header_repr_number():
@@ -104,11 +83,7 @@ def test_cookie_repr_none():
 
 
 def test_cookie_repr_ellipsis():
-    assert repr(Cookie(...)) == IsOneOf(
-        "Cookie(PydanticUndefined)",
-        # TODO: remove when deprecating Pydantic v1
-        "Cookie(Ellipsis)",
-    )
+    assert repr(Cookie(...)) == "Cookie(PydanticUndefined)"
 
 
 def test_cookie_repr_number():
@@ -128,11 +103,7 @@ def test_body_repr_none():
 
 
 def test_body_repr_ellipsis():
-    assert repr(Body(...)) == IsOneOf(
-        "Body(PydanticUndefined)",
-        # TODO: remove when deprecating Pydantic v1
-        "Body(Ellipsis)",
-    )
+    assert repr(Body(...)) == "Body(PydanticUndefined)"
 
 
 def test_body_repr_number():
index 09c1f13fb157369194f089d8ea8b9619d3ab483e..47051b927cc371638a3a30d05d061ee78cac57bd 100644 (file)
@@ -1,4 +1,3 @@
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from .main import app
@@ -45,57 +44,31 @@ def test_path_str_True():
 def test_path_int_foobar():
     response = client.get("/path/int/foobar")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "foobar",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "foobar",
+            }
+        ]
+    }
 
 
 def test_path_int_True():
     response = client.get("/path/int/True")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "True",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "True",
+            }
+        ]
+    }
 
 
 def test_path_int_42():
@@ -107,85 +80,46 @@ def test_path_int_42():
 def test_path_int_42_5():
     response = client.get("/path/int/42.5")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "42.5",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "42.5",
+            }
+        ]
+    }
 
 
 def test_path_float_foobar():
     response = client.get("/path/float/foobar")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "float_parsing",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be a valid number, unable to parse string as a number",
-                    "input": "foobar",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "value is not a valid float",
-                    "type": "type_error.float",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "float_parsing",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be a valid number, unable to parse string as a number",
+                "input": "foobar",
+            }
+        ]
+    }
 
 
 def test_path_float_True():
     response = client.get("/path/float/True")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "float_parsing",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be a valid number, unable to parse string as a number",
-                    "input": "True",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "value is not a valid float",
-                    "type": "type_error.float",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "float_parsing",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be a valid number, unable to parse string as a number",
+                "input": "True",
+            }
+        ]
+    }
 
 
 def test_path_float_42():
@@ -203,29 +137,16 @@ def test_path_float_42_5():
 def test_path_bool_foobar():
     response = client.get("/path/bool/foobar")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "bool_parsing",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be a valid boolean, unable to interpret input",
-                    "input": "foobar",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "value could not be parsed to a boolean",
-                    "type": "type_error.bool",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "bool_parsing",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be a valid boolean, unable to interpret input",
+                "input": "foobar",
+            }
+        ]
+    }
 
 
 def test_path_bool_True():
@@ -237,57 +158,31 @@ def test_path_bool_True():
 def test_path_bool_42():
     response = client.get("/path/bool/42")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "bool_parsing",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be a valid boolean, unable to interpret input",
-                    "input": "42",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "value could not be parsed to a boolean",
-                    "type": "type_error.bool",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "bool_parsing",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be a valid boolean, unable to interpret input",
+                "input": "42",
+            }
+        ]
+    }
 
 
 def test_path_bool_42_5():
     response = client.get("/path/bool/42.5")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "bool_parsing",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be a valid boolean, unable to interpret input",
-                    "input": "42.5",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "value could not be parsed to a boolean",
-                    "type": "type_error.bool",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "bool_parsing",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be a valid boolean, unable to interpret input",
+                "input": "42.5",
+            }
+        ]
+    }
 
 
 def test_path_bool_1():
@@ -335,31 +230,17 @@ def test_path_param_minlength_foo():
 def test_path_param_minlength_fo():
     response = client.get("/path/param-minlength/fo")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "string_too_short",
-                    "loc": ["path", "item_id"],
-                    "msg": "String should have at least 3 characters",
-                    "input": "fo",
-                    "ctx": {"min_length": 3},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value has at least 3 characters",
-                    "type": "value_error.any_str.min_length",
-                    "ctx": {"limit_value": 3},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "string_too_short",
+                "loc": ["path", "item_id"],
+                "msg": "String should have at least 3 characters",
+                "input": "fo",
+                "ctx": {"min_length": 3},
+            }
+        ]
+    }
 
 
 def test_path_param_maxlength_foo():
@@ -371,31 +252,17 @@ def test_path_param_maxlength_foo():
 def test_path_param_maxlength_foobar():
     response = client.get("/path/param-maxlength/foobar")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "string_too_long",
-                    "loc": ["path", "item_id"],
-                    "msg": "String should have at most 3 characters",
-                    "input": "foobar",
-                    "ctx": {"max_length": 3},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value has at most 3 characters",
-                    "type": "value_error.any_str.max_length",
-                    "ctx": {"limit_value": 3},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "string_too_long",
+                "loc": ["path", "item_id"],
+                "msg": "String should have at most 3 characters",
+                "input": "foobar",
+                "ctx": {"max_length": 3},
+            }
+        ]
+    }
 
 
 def test_path_param_min_maxlength_foo():
@@ -407,60 +274,33 @@ def test_path_param_min_maxlength_foo():
 def test_path_param_min_maxlength_foobar():
     response = client.get("/path/param-min_maxlength/foobar")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "string_too_long",
-                    "loc": ["path", "item_id"],
-                    "msg": "String should have at most 3 characters",
-                    "input": "foobar",
-                    "ctx": {"max_length": 3},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value has at most 3 characters",
-                    "type": "value_error.any_str.max_length",
-                    "ctx": {"limit_value": 3},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "string_too_long",
+                "loc": ["path", "item_id"],
+                "msg": "String should have at most 3 characters",
+                "input": "foobar",
+                "ctx": {"max_length": 3},
+            }
+        ]
+    }
 
 
 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():
@@ -472,31 +312,17 @@ def test_path_param_gt_42():
 def test_path_param_gt_2():
     response = client.get("/path/param-gt/2")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "greater_than",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be greater than 3",
-                    "input": "2",
-                    "ctx": {"gt": 3.0},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value is greater than 3",
-                    "type": "value_error.number.not_gt",
-                    "ctx": {"limit_value": 3},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "greater_than",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be greater than 3",
+                "input": "2",
+                "ctx": {"gt": 3.0},
+            }
+        ]
+    }
 
 
 def test_path_param_gt0_0_05():
@@ -508,31 +334,17 @@ def test_path_param_gt0_0_05():
 def test_path_param_gt0_0():
     response = client.get("/path/param-gt0/0")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "greater_than",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be greater than 0",
-                    "input": "0",
-                    "ctx": {"gt": 0.0},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value is greater than 0",
-                    "type": "value_error.number.not_gt",
-                    "ctx": {"limit_value": 0},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "greater_than",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be greater than 0",
+                "input": "0",
+                "ctx": {"gt": 0.0},
+            }
+        ]
+    }
 
 
 def test_path_param_ge_42():
@@ -550,61 +362,33 @@ def test_path_param_ge_3():
 def test_path_param_ge_2():
     response = client.get("/path/param-ge/2")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "greater_than_equal",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be greater than or equal to 3",
-                    "input": "2",
-                    "ctx": {"ge": 3.0},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value is greater than or equal to 3",
-                    "type": "value_error.number.not_ge",
-                    "ctx": {"limit_value": 3},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "greater_than_equal",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be greater than or equal to 3",
+                "input": "2",
+                "ctx": {"ge": 3.0},
+            }
+        ]
+    }
 
 
 def test_path_param_lt_42():
     response = client.get("/path/param-lt/42")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "less_than",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be less than 3",
-                    "input": "42",
-                    "ctx": {"lt": 3.0},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value is less than 3",
-                    "type": "value_error.number.not_lt",
-                    "ctx": {"limit_value": 3},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "less_than",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be less than 3",
+                "input": "42",
+                "ctx": {"lt": 3.0},
+            }
+        ]
+    }
 
 
 def test_path_param_lt_2():
@@ -622,61 +406,33 @@ def test_path_param_lt0__1():
 def test_path_param_lt0_0():
     response = client.get("/path/param-lt0/0")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "less_than",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be less than 0",
-                    "input": "0",
-                    "ctx": {"lt": 0.0},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value is less than 0",
-                    "type": "value_error.number.not_lt",
-                    "ctx": {"limit_value": 0},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "less_than",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be less than 0",
+                "input": "0",
+                "ctx": {"lt": 0.0},
+            }
+        ]
+    }
 
 
 def test_path_param_le_42():
     response = client.get("/path/param-le/42")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "less_than_equal",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be less than or equal to 3",
-                    "input": "42",
-                    "ctx": {"le": 3.0},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value is less than or equal to 3",
-                    "type": "value_error.number.not_le",
-                    "ctx": {"limit_value": 3},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "less_than_equal",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be less than or equal to 3",
+                "input": "42",
+                "ctx": {"le": 3.0},
+            }
+        ]
+    }
 
 
 def test_path_param_le_3():
@@ -700,61 +456,33 @@ def test_path_param_lt_gt_2():
 def test_path_param_lt_gt_4():
     response = client.get("/path/param-lt-gt/4")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "less_than",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be less than 3",
-                    "input": "4",
-                    "ctx": {"lt": 3.0},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value is less than 3",
-                    "type": "value_error.number.not_lt",
-                    "ctx": {"limit_value": 3},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "less_than",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be less than 3",
+                "input": "4",
+                "ctx": {"lt": 3.0},
+            }
+        ]
+    }
 
 
 def test_path_param_lt_gt_0():
     response = client.get("/path/param-lt-gt/0")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "greater_than",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be greater than 1",
-                    "input": "0",
-                    "ctx": {"gt": 1.0},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value is greater than 1",
-                    "type": "value_error.number.not_gt",
-                    "ctx": {"limit_value": 1},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "greater_than",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be greater than 1",
+                "input": "0",
+                "ctx": {"gt": 1.0},
+            }
+        ]
+    }
 
 
 def test_path_param_le_ge_2():
@@ -777,31 +505,17 @@ def test_path_param_le_ge_3():
 def test_path_param_le_ge_4():
     response = client.get("/path/param-le-ge/4")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "less_than_equal",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be less than or equal to 3",
-                    "input": "4",
-                    "ctx": {"le": 3.0},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value is less than or equal to 3",
-                    "type": "value_error.number.not_le",
-                    "ctx": {"limit_value": 3},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "less_than_equal",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be less than or equal to 3",
+                "input": "4",
+                "ctx": {"le": 3.0},
+            }
+        ]
+    }
 
 
 def test_path_param_lt_int_2():
@@ -813,59 +527,32 @@ def test_path_param_lt_int_2():
 def test_path_param_lt_int_42():
     response = client.get("/path/param-lt-int/42")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "less_than",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be less than 3",
-                    "input": "42",
-                    "ctx": {"lt": 3},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value is less than 3",
-                    "type": "value_error.number.not_lt",
-                    "ctx": {"limit_value": 3},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "less_than",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be less than 3",
+                "input": "42",
+                "ctx": {"lt": 3},
+            }
+        ]
+    }
 
 
 def test_path_param_lt_int_2_7():
     response = client.get("/path/param-lt-int/2.7")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "2.7",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "2.7",
+            }
+        ]
+    }
 
 
 def test_path_param_gt_int_42():
@@ -877,89 +564,48 @@ def test_path_param_gt_int_42():
 def test_path_param_gt_int_2():
     response = client.get("/path/param-gt-int/2")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "greater_than",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be greater than 3",
-                    "input": "2",
-                    "ctx": {"gt": 3},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value is greater than 3",
-                    "type": "value_error.number.not_gt",
-                    "ctx": {"limit_value": 3},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "greater_than",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be greater than 3",
+                "input": "2",
+                "ctx": {"gt": 3},
+            }
+        ]
+    }
 
 
 def test_path_param_gt_int_2_7():
     response = client.get("/path/param-gt-int/2.7")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "2.7",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "2.7",
+            }
+        ]
+    }
 
 
 def test_path_param_le_int_42():
     response = client.get("/path/param-le-int/42")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "less_than_equal",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be less than or equal to 3",
-                    "input": "42",
-                    "ctx": {"le": 3},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value is less than or equal to 3",
-                    "type": "value_error.number.not_le",
-                    "ctx": {"limit_value": 3},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "less_than_equal",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be less than or equal to 3",
+                "input": "42",
+                "ctx": {"le": 3},
+            }
+        ]
+    }
 
 
 def test_path_param_le_int_3():
@@ -977,29 +623,16 @@ def test_path_param_le_int_2():
 def test_path_param_le_int_2_7():
     response = client.get("/path/param-le-int/2.7")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "2.7",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "2.7",
+            }
+        ]
+    }
 
 
 def test_path_param_ge_int_42():
@@ -1017,59 +650,32 @@ def test_path_param_ge_int_3():
 def test_path_param_ge_int_2():
     response = client.get("/path/param-ge-int/2")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "greater_than_equal",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be greater than or equal to 3",
-                    "input": "2",
-                    "ctx": {"ge": 3},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value is greater than or equal to 3",
-                    "type": "value_error.number.not_ge",
-                    "ctx": {"limit_value": 3},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "greater_than_equal",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be greater than or equal to 3",
+                "input": "2",
+                "ctx": {"ge": 3},
+            }
+        ]
+    }
 
 
 def test_path_param_ge_int_2_7():
     response = client.get("/path/param-ge-int/2.7")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "2.7",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "2.7",
+            }
+        ]
+    }
 
 
 def test_path_param_lt_gt_int_2():
@@ -1081,89 +687,48 @@ def test_path_param_lt_gt_int_2():
 def test_path_param_lt_gt_int_4():
     response = client.get("/path/param-lt-gt-int/4")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "less_than",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be less than 3",
-                    "input": "4",
-                    "ctx": {"lt": 3},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value is less than 3",
-                    "type": "value_error.number.not_lt",
-                    "ctx": {"limit_value": 3},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "less_than",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be less than 3",
+                "input": "4",
+                "ctx": {"lt": 3},
+            }
+        ]
+    }
 
 
 def test_path_param_lt_gt_int_0():
     response = client.get("/path/param-lt-gt-int/0")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "greater_than",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be greater than 1",
-                    "input": "0",
-                    "ctx": {"gt": 1},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value is greater than 1",
-                    "type": "value_error.number.not_gt",
-                    "ctx": {"limit_value": 1},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "greater_than",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be greater than 1",
+                "input": "0",
+                "ctx": {"gt": 1},
+            }
+        ]
+    }
 
 
 def test_path_param_lt_gt_int_2_7():
     response = client.get("/path/param-lt-gt-int/2.7")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "2.7",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "2.7",
+            }
+        ]
+    }
 
 
 def test_path_param_le_ge_int_2():
@@ -1187,56 +752,29 @@ def test_path_param_le_ge_int_3():
 def test_path_param_le_ge_int_4():
     response = client.get("/path/param-le-ge-int/4")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "less_than_equal",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be less than or equal to 3",
-                    "input": "4",
-                    "ctx": {"le": 3},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "ensure this value is less than or equal to 3",
-                    "type": "value_error.number.not_le",
-                    "ctx": {"limit_value": 3},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "less_than_equal",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be less than or equal to 3",
+                "input": "4",
+                "ctx": {"le": 3},
+            }
+        ]
+    }
 
 
 def test_path_param_le_ge_int_2_7():
     response = client.get("/path/param-le-ge-int/2.7")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "2.7",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "2.7",
+            }
+        ]
+    }
index 57f551d2ab22c22c1d8526e1d7d8070e09931616..c25960cacaef766e157a8c0db73b6b26fb003492 100644 (file)
@@ -1,4 +1,3 @@
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from .main import app
@@ -9,29 +8,16 @@ client = TestClient(app)
 def test_query():
     response = client.get("/query")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "query"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "query"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "query"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_query_query_baz():
@@ -43,29 +29,16 @@ def test_query_query_baz():
 def test_query_not_declared_baz():
     response = client.get("/query?not_declared=baz")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "query"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "query"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "query"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_query_optional():
@@ -89,29 +62,16 @@ def test_query_optional_not_declared_baz():
 def test_query_int():
     response = client.get("/query/int")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "query"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "query"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "query"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_query_int_query_42():
@@ -123,85 +83,46 @@ def test_query_int_query_42():
 def test_query_int_query_42_5():
     response = client.get("/query/int?query=42.5")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["query", "query"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "42.5",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "query"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["query", "query"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "42.5",
+            }
+        ]
+    }
 
 
 def test_query_int_query_baz():
     response = client.get("/query/int?query=baz")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["query", "query"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "baz",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "query"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["query", "query"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "baz",
+            }
+        ]
+    }
 
 
 def test_query_int_not_declared_baz():
     response = client.get("/query/int?not_declared=baz")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "query"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "query"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "query"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_query_int_optional():
@@ -219,29 +140,16 @@ def test_query_int_optional_query_50():
 def test_query_int_optional_query_foo():
     response = client.get("/query/int/optional?query=foo")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["query", "query"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "foo",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "query"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["query", "query"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "foo",
+            }
+        ]
+    }
 
 
 def test_query_int_default():
@@ -259,29 +167,16 @@ def test_query_int_default_query_50():
 def test_query_int_default_query_foo():
     response = client.get("/query/int/default?query=foo")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["query", "query"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "foo",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "query"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["query", "query"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "foo",
+            }
+        ]
+    }
 
 
 def test_query_param():
@@ -299,29 +194,16 @@ def test_query_param_query_50():
 def test_query_param_required():
     response = client.get("/query/param-required")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "query"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "query"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "query"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_query_param_required_query_50():
@@ -333,29 +215,16 @@ def test_query_param_required_query_50():
 def test_query_param_required_int():
     response = client.get("/query/param-required/int")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "query"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "query"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "query"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_query_param_required_int_query_50():
@@ -367,29 +236,16 @@ def test_query_param_required_int_query_50():
 def test_query_param_required_int_query_foo():
     response = client.get("/query/param-required/int?query=foo")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["query", "query"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "foo",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "query"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["query", "query"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "foo",
+            }
+        ]
+    }
 
 
 def test_query_frozenset_query_1_query_1_query_2():
index 9d58c5dae17224fff25a9f2c9a0abe967d69693b..5b4daa450f467cef881efc13e4efec7ac77ce51f 100644 (file)
@@ -1,10 +1,10 @@
 from typing import Annotated
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import FastAPI, Form
 from fastapi.exceptions import FastAPIDeprecationWarning
 from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
 
 from .utils import needs_py310
 
@@ -47,31 +47,17 @@ def test_query_nonregexquery():
     client = get_client()
     response = client.post("/items/", data={"q": "nonregexquery"})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "string_pattern_mismatch",
-                    "loc": ["body", "q"],
-                    "msg": "String should match pattern '^fixedquery$'",
-                    "input": "nonregexquery",
-                    "ctx": {"pattern": "^fixedquery$"},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "ctx": {"pattern": "^fixedquery$"},
-                    "loc": ["body", "q"],
-                    "msg": 'string does not match regex "^fixedquery$"',
-                    "type": "value_error.str.regex",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "string_pattern_mismatch",
+                "loc": ["body", "q"],
+                "msg": "String should match pattern '^fixedquery$'",
+                "input": "nonregexquery",
+                "ctx": {"pattern": "^fixedquery$"},
+            }
+        ]
+    }
 
 
 @needs_py310
@@ -79,104 +65,88 @@ def test_openapi_schema():
     client = get_client()
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    # insert_assert(response.json())
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/": {
-                "post": {
-                    "summary": "Read Items",
-                    "operationId": "read_items_items__post",
-                    "requestBody": {
-                        "content": {
-                            "application/x-www-form-urlencoded": {
-                                "schema": IsDict(
-                                    {
-                                        "allOf": [
-                                            {
-                                                "$ref": "#/components/schemas/Body_read_items_items__post"
-                                            }
-                                        ],
-                                        "title": "Body",
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {
+    assert response.json() == snapshot(
+        {
+            "openapi": "3.1.0",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "paths": {
+                "/items/": {
+                    "post": {
+                        "summary": "Read Items",
+                        "operationId": "read_items_items__post",
+                        "requestBody": {
+                            "content": {
+                                "application/x-www-form-urlencoded": {
+                                    "schema": {
                                         "$ref": "#/components/schemas/Body_read_items_items__post"
                                     }
-                                )
+                                }
                             }
-                        }
-                    },
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
                         },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {"application/json": {"schema": {}}},
+                            },
+                            "422": {
+                                "description": "Validation Error",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/HTTPValidationError"
+                                        }
                                     }
-                                }
+                                },
                             },
                         },
-                    },
+                    }
                 }
-            }
-        },
-        "components": {
-            "schemas": {
-                "Body_read_items_items__post": {
-                    "properties": {
-                        "q": IsDict(
-                            {
+            },
+            "components": {
+                "schemas": {
+                    "Body_read_items_items__post": {
+                        "properties": {
+                            "q": {
                                 "anyOf": [
                                     {"type": "string", "pattern": "^fixedquery$"},
                                     {"type": "null"},
                                 ],
                                 "title": "Q",
                             }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"type": "string", "pattern": "^fixedquery$", "title": "Q"}
-                        )
+                        },
+                        "type": "object",
+                        "title": "Body_read_items_items__post",
                     },
-                    "type": "object",
-                    "title": "Body_read_items_items__post",
-                },
-                "HTTPValidationError": {
-                    "properties": {
-                        "detail": {
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                            "type": "array",
-                            "title": "Detail",
-                        }
+                    "HTTPValidationError": {
+                        "properties": {
+                            "detail": {
+                                "items": {
+                                    "$ref": "#/components/schemas/ValidationError"
+                                },
+                                "type": "array",
+                                "title": "Detail",
+                            }
+                        },
+                        "type": "object",
+                        "title": "HTTPValidationError",
                     },
-                    "type": "object",
-                    "title": "HTTPValidationError",
-                },
-                "ValidationError": {
-                    "properties": {
-                        "loc": {
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                    "ValidationError": {
+                        "properties": {
+                            "loc": {
+                                "items": {
+                                    "anyOf": [{"type": "string"}, {"type": "integer"}]
+                                },
+                                "type": "array",
+                                "title": "Location",
                             },
-                            "type": "array",
-                            "title": "Location",
+                            "msg": {"type": "string", "title": "Message"},
+                            "type": {"type": "string", "title": "Error Type"},
                         },
-                        "msg": {"type": "string", "title": "Message"},
-                        "type": {"type": "string", "title": "Error Type"},
+                        "type": "object",
+                        "required": ["loc", "msg", "type"],
+                        "title": "ValidationError",
                     },
-                    "type": "object",
-                    "required": ["loc", "msg", "type"],
-                    "title": "ValidationError",
-                },
-            }
-        },
-    }
+                }
+            },
+        }
+    )
index 8973657a9034c64f2cbd666fef6c094df2cee426..d6eaa45fb1ba8a582cf4659791e0da09f9268cb5 100644 (file)
@@ -1,7 +1,6 @@
 from typing import Annotated
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import FastAPI, Query
 from fastapi.exceptions import FastAPIDeprecationWarning
 from fastapi.testclient import TestClient
@@ -47,31 +46,17 @@ def test_query_params_str_validations_item_query_nonregexquery():
     client = get_client()
     response = client.get("/items/", params={"q": "nonregexquery"})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "string_pattern_mismatch",
-                    "loc": ["query", "q"],
-                    "msg": "String should match pattern '^fixedquery$'",
-                    "input": "nonregexquery",
-                    "ctx": {"pattern": "^fixedquery$"},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "ctx": {"pattern": "^fixedquery$"},
-                    "loc": ["query", "q"],
-                    "msg": 'string does not match regex "^fixedquery$"',
-                    "type": "value_error.str.regex",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "string_pattern_mismatch",
+                "loc": ["query", "q"],
+                "msg": "String should match pattern '^fixedquery$'",
+                "input": "nonregexquery",
+                "ctx": {"pattern": "^fixedquery$"},
+            }
+        ]
+    }
 
 
 @needs_py310
@@ -93,23 +78,13 @@ def test_openapi_schema():
                             "name": "q",
                             "in": "query",
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [
-                                        {"type": "string", "pattern": "^fixedquery$"},
-                                        {"type": "null"},
-                                    ],
-                                    "title": "Q",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {
-                                    "type": "string",
-                                    "pattern": "^fixedquery$",
-                                    "title": "Q",
-                                }
-                            ),
+                            "schema": {
+                                "anyOf": [
+                                    {"type": "string", "pattern": "^fixedquery$"},
+                                    {"type": "null"},
+                                ],
+                                "title": "Q",
+                            },
                         }
                     ],
                     "responses": {
index 0048da0f8bcb32d86d13a9a4b4b2642c74700561..50847335ce7b94b83793c6e8221dc8eb37e8ce97 100644 (file)
@@ -148,29 +148,16 @@ def test_required_list_alias_missing(path: str, json: Union[dict, None]):
     client = TestClient(app)
     response = client.post(path, json=json)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": IsOneOf(["body", "p_alias"], ["body"]),
-                    "msg": "Field required",
-                    "input": IsOneOf(None, {}),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": IsOneOf(["body", "p_alias"], ["body"]),
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": IsOneOf(["body", "p_alias"], ["body"]),
+                "msg": "Field required",
+                "input": IsOneOf(None, {}),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -181,29 +168,16 @@ def test_required_list_alias_by_name(path: str):
     client = TestClient(app)
     response = client.post(path, json={"p": ["hello", "world"]})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "p_alias"],
-                    "msg": "Field required",
-                    "input": IsOneOf(None, {"p": ["hello", "world"]}),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "p_alias"],
+                "msg": "Field required",
+                "input": IsOneOf(None, {"p": ["hello", "world"]}),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
index 960e8890f3900970b9af9edd4a7a8feb7cf15ed2..ba8ba9092ee9ca2cd00fcfcf7e6ddc692b551228 100644 (file)
@@ -1,7 +1,6 @@
 from typing import Annotated, Optional
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import Body, FastAPI
 from fastapi.testclient import TestClient
 from pydantic import BaseModel, Field
@@ -38,30 +37,19 @@ def test_optional_list_str_schema(path: str):
     openapi = app.openapi()
     body_model_name = get_body_model_name(openapi, path)
 
-    assert app.openapi()["components"]["schemas"][body_model_name] == IsDict(
-        {
-            "properties": {
-                "p": {
-                    "anyOf": [
-                        {"items": {"type": "string"}, "type": "array"},
-                        {"type": "null"},
-                    ],
-                    "title": "P",
-                },
+    assert app.openapi()["components"]["schemas"][body_model_name] == {
+        "properties": {
+            "p": {
+                "anyOf": [
+                    {"items": {"type": "string"}, "type": "array"},
+                    {"type": "null"},
+                ],
+                "title": "P",
             },
-            "title": body_model_name,
-            "type": "object",
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "properties": {
-                "p": {"items": {"type": "string"}, "type": "array", "title": "P"},
-            },
-            "title": body_model_name,
-            "type": "object",
-        }
-    )
+        },
+        "title": body_model_name,
+        "type": "object",
+    }
 
 
 def test_optional_list_str_missing():
@@ -75,29 +63,16 @@ def test_model_optional_list_str_missing():
     client = TestClient(app)
     response = client.post("/model-optional-list-str")
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "input": None,
-                    "loc": ["body"],
-                    "msg": "Field required",
-                    "type": "missing",
-                },
-            ],
-        }
-    ) | IsDict(
-        {
-            # TODO: remove when deprecating Pydantic v1
-            "detail": [
-                {
-                    "loc": ["body"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ],
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "input": None,
+                "loc": ["body"],
+                "msg": "Field required",
+                "type": "missing",
+            },
+        ],
+    }
 
 
 @pytest.mark.parametrize(
@@ -153,34 +128,19 @@ def test_optional_list_str_alias_schema(path: str):
     openapi = app.openapi()
     body_model_name = get_body_model_name(openapi, path)
 
-    assert app.openapi()["components"]["schemas"][body_model_name] == IsDict(
-        {
-            "properties": {
-                "p_alias": {
-                    "anyOf": [
-                        {"items": {"type": "string"}, "type": "array"},
-                        {"type": "null"},
-                    ],
-                    "title": "P Alias",
-                },
+    assert app.openapi()["components"]["schemas"][body_model_name] == {
+        "properties": {
+            "p_alias": {
+                "anyOf": [
+                    {"items": {"type": "string"}, "type": "array"},
+                    {"type": "null"},
+                ],
+                "title": "P Alias",
             },
-            "title": body_model_name,
-            "type": "object",
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "properties": {
-                "p_alias": {
-                    "items": {"type": "string"},
-                    "type": "array",
-                    "title": "P Alias",
-                },
-            },
-            "title": body_model_name,
-            "type": "object",
-        }
-    )
+        },
+        "title": body_model_name,
+        "type": "object",
+    }
 
 
 def test_optional_list_alias_missing():
@@ -194,29 +154,16 @@ def test_model_optional_list_alias_missing():
     client = TestClient(app)
     response = client.post("/model-optional-list-alias")
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "input": None,
-                    "loc": ["body"],
-                    "msg": "Field required",
-                    "type": "missing",
-                },
-            ],
-        }
-    ) | IsDict(
-        {
-            # TODO: remove when deprecating Pydantic v1
-            "detail": [
-                {
-                    "loc": ["body"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ],
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "input": None,
+                "loc": ["body"],
+                "msg": "Field required",
+                "type": "missing",
+            },
+        ],
+    }
 
 
 @pytest.mark.parametrize(
@@ -289,34 +236,19 @@ def test_optional_list_validation_alias_schema(path: str):
     openapi = app.openapi()
     body_model_name = get_body_model_name(openapi, path)
 
-    assert app.openapi()["components"]["schemas"][body_model_name] == IsDict(
-        {
-            "properties": {
-                "p_val_alias": {
-                    "anyOf": [
-                        {"items": {"type": "string"}, "type": "array"},
-                        {"type": "null"},
-                    ],
-                    "title": "P Val Alias",
-                },
+    assert app.openapi()["components"]["schemas"][body_model_name] == {
+        "properties": {
+            "p_val_alias": {
+                "anyOf": [
+                    {"items": {"type": "string"}, "type": "array"},
+                    {"type": "null"},
+                ],
+                "title": "P Val Alias",
             },
-            "title": body_model_name,
-            "type": "object",
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "properties": {
-                "p_val_alias": {
-                    "items": {"type": "string"},
-                    "type": "array",
-                    "title": "P Val Alias",
-                },
-            },
-            "title": body_model_name,
-            "type": "object",
-        }
-    )
+        },
+        "title": body_model_name,
+        "type": "object",
+    }
 
 
 def test_optional_list_validation_alias_missing():
@@ -330,29 +262,16 @@ def test_model_optional_list_validation_alias_missing():
     client = TestClient(app)
     response = client.post("/model-optional-list-validation-alias")
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "input": None,
-                    "loc": ["body"],
-                    "msg": "Field required",
-                    "type": "missing",
-                },
-            ],
-        }
-    ) | IsDict(
-        {
-            # TODO: remove when deprecating Pydantic v1
-            "detail": [
-                {
-                    "loc": ["body"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ],
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "input": None,
+                "loc": ["body"],
+                "msg": "Field required",
+                "type": "missing",
+            },
+        ],
+    }
 
 
 @pytest.mark.parametrize(
@@ -438,34 +357,19 @@ def test_optional_list_alias_and_validation_alias_schema(path: str):
     openapi = app.openapi()
     body_model_name = get_body_model_name(openapi, path)
 
-    assert app.openapi()["components"]["schemas"][body_model_name] == IsDict(
-        {
-            "properties": {
-                "p_val_alias": {
-                    "anyOf": [
-                        {"items": {"type": "string"}, "type": "array"},
-                        {"type": "null"},
-                    ],
-                    "title": "P Val Alias",
-                },
+    assert app.openapi()["components"]["schemas"][body_model_name] == {
+        "properties": {
+            "p_val_alias": {
+                "anyOf": [
+                    {"items": {"type": "string"}, "type": "array"},
+                    {"type": "null"},
+                ],
+                "title": "P Val Alias",
             },
-            "title": body_model_name,
-            "type": "object",
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "properties": {
-                "p_val_alias": {
-                    "items": {"type": "string"},
-                    "type": "array",
-                    "title": "P Val Alias",
-                },
-            },
-            "title": body_model_name,
-            "type": "object",
-        }
-    )
+        },
+        "title": body_model_name,
+        "type": "object",
+    }
 
 
 def test_optional_list_alias_and_validation_alias_missing():
@@ -479,29 +383,16 @@ def test_model_optional_list_alias_and_validation_alias_missing():
     client = TestClient(app)
     response = client.post("/model-optional-list-alias-and-validation-alias")
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "input": None,
-                    "loc": ["body"],
-                    "msg": "Field required",
-                    "type": "missing",
-                },
-            ],
-        }
-    ) | IsDict(
-        {
-            # TODO: remove when deprecating Pydantic v1
-            "detail": [
-                {
-                    "loc": ["body"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ],
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "input": None,
+                "loc": ["body"],
+                "msg": "Field required",
+                "type": "missing",
+            },
+        ],
+    }
 
 
 @pytest.mark.parametrize(
index 59732688a2654844a5b76d7c9f5f23e3929d9e45..b9c18034da420f415068eaf021fe86013260c31c 100644 (file)
@@ -1,7 +1,6 @@
 from typing import Annotated, Optional
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import Body, FastAPI
 from fastapi.testclient import TestClient
 from pydantic import BaseModel, Field
@@ -36,27 +35,16 @@ def test_optional_str_schema(path: str):
     openapi = app.openapi()
     body_model_name = get_body_model_name(openapi, path)
 
-    assert app.openapi()["components"]["schemas"][body_model_name] == IsDict(
-        {
-            "properties": {
-                "p": {
-                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                    "title": "P",
-                },
+    assert app.openapi()["components"]["schemas"][body_model_name] == {
+        "properties": {
+            "p": {
+                "anyOf": [{"type": "string"}, {"type": "null"}],
+                "title": "P",
             },
-            "title": body_model_name,
-            "type": "object",
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "properties": {
-                "p": {"type": "string", "title": "P"},
-            },
-            "title": body_model_name,
-            "type": "object",
-        }
-    )
+        },
+        "title": body_model_name,
+        "type": "object",
+    }
 
 
 def test_optional_str_missing():
@@ -70,29 +58,16 @@ def test_model_optional_str_missing():
     client = TestClient(app)
     response = client.post("/model-optional-str")
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "input": None,
-                    "loc": ["body"],
-                    "msg": "Field required",
-                    "type": "missing",
-                },
-            ],
-        }
-    ) | IsDict(
-        {
-            # TODO: remove when deprecating Pydantic v1
-            "detail": [
-                {
-                    "loc": ["body"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ],
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "input": None,
+                "loc": ["body"],
+                "msg": "Field required",
+                "type": "missing",
+            },
+        ],
+    }
 
 
 @pytest.mark.parametrize(
@@ -148,27 +123,16 @@ def test_optional_str_alias_schema(path: str):
     openapi = app.openapi()
     body_model_name = get_body_model_name(openapi, path)
 
-    assert app.openapi()["components"]["schemas"][body_model_name] == IsDict(
-        {
-            "properties": {
-                "p_alias": {
-                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                    "title": "P Alias",
-                },
+    assert app.openapi()["components"]["schemas"][body_model_name] == {
+        "properties": {
+            "p_alias": {
+                "anyOf": [{"type": "string"}, {"type": "null"}],
+                "title": "P Alias",
             },
-            "title": body_model_name,
-            "type": "object",
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "properties": {
-                "p_alias": {"type": "string", "title": "P Alias"},
-            },
-            "title": body_model_name,
-            "type": "object",
-        }
-    )
+        },
+        "title": body_model_name,
+        "type": "object",
+    }
 
 
 def test_optional_alias_missing():
@@ -182,29 +146,16 @@ def test_model_optional_alias_missing():
     client = TestClient(app)
     response = client.post("/model-optional-alias")
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "input": None,
-                    "loc": ["body"],
-                    "msg": "Field required",
-                    "type": "missing",
-                },
-            ],
-        }
-    ) | IsDict(
-        {
-            # TODO: remove when deprecating Pydantic v1
-            "detail": [
-                {
-                    "loc": ["body"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ],
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "input": None,
+                "loc": ["body"],
+                "msg": "Field required",
+                "type": "missing",
+            },
+        ],
+    }
 
 
 @pytest.mark.parametrize(
@@ -274,27 +225,16 @@ def test_optional_validation_alias_schema(path: str):
     openapi = app.openapi()
     body_model_name = get_body_model_name(openapi, path)
 
-    assert app.openapi()["components"]["schemas"][body_model_name] == IsDict(
-        {
-            "properties": {
-                "p_val_alias": {
-                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                    "title": "P Val Alias",
-                },
+    assert app.openapi()["components"]["schemas"][body_model_name] == {
+        "properties": {
+            "p_val_alias": {
+                "anyOf": [{"type": "string"}, {"type": "null"}],
+                "title": "P Val Alias",
             },
-            "title": body_model_name,
-            "type": "object",
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "properties": {
-                "p_val_alias": {"type": "string", "title": "P Val Alias"},
-            },
-            "title": body_model_name,
-            "type": "object",
-        }
-    )
+        },
+        "title": body_model_name,
+        "type": "object",
+    }
 
 
 def test_optional_validation_alias_missing():
@@ -308,29 +248,16 @@ def test_model_optional_validation_alias_missing():
     client = TestClient(app)
     response = client.post("/model-optional-validation-alias")
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "input": None,
-                    "loc": ["body"],
-                    "msg": "Field required",
-                    "type": "missing",
-                },
-            ],
-        }
-    ) | IsDict(
-        {
-            # TODO: remove when deprecating Pydantic v1
-            "detail": [
-                {
-                    "loc": ["body"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ],
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "input": None,
+                "loc": ["body"],
+                "msg": "Field required",
+                "type": "missing",
+            },
+        ],
+    }
 
 
 @pytest.mark.parametrize(
@@ -413,27 +340,16 @@ def test_optional_alias_and_validation_alias_schema(path: str):
     openapi = app.openapi()
     body_model_name = get_body_model_name(openapi, path)
 
-    assert app.openapi()["components"]["schemas"][body_model_name] == IsDict(
-        {
-            "properties": {
-                "p_val_alias": {
-                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                    "title": "P Val Alias",
-                },
+    assert app.openapi()["components"]["schemas"][body_model_name] == {
+        "properties": {
+            "p_val_alias": {
+                "anyOf": [{"type": "string"}, {"type": "null"}],
+                "title": "P Val Alias",
             },
-            "title": body_model_name,
-            "type": "object",
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "properties": {
-                "p_val_alias": {"type": "string", "title": "P Val Alias"},
-            },
-            "title": body_model_name,
-            "type": "object",
-        }
-    )
+        },
+        "title": body_model_name,
+        "type": "object",
+    }
 
 
 def test_optional_alias_and_validation_alias_missing():
@@ -447,29 +363,16 @@ def test_model_optional_alias_and_validation_alias_missing():
     client = TestClient(app)
     response = client.post("/model-optional-alias-and-validation-alias")
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "input": None,
-                    "loc": ["body"],
-                    "msg": "Field required",
-                    "type": "missing",
-                },
-            ],
-        }
-    ) | IsDict(
-        {
-            # TODO: remove when deprecating Pydantic v1
-            "detail": [
-                {
-                    "loc": ["body"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ],
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "input": None,
+                "loc": ["body"],
+                "msg": "Field required",
+                "type": "missing",
+            },
+        ],
+    }
 
 
 @pytest.mark.parametrize(
index 5571ba5d5a79f3cac2998d41cf53a95980d2ec0c..5b434fa1dbf28d999e11d4579746dc3ed136de99 100644 (file)
@@ -1,7 +1,7 @@
 from typing import Annotated, Any, Union
 
 import pytest
-from dirty_equals import IsDict, IsOneOf
+from dirty_equals import IsOneOf
 from fastapi import Body, FastAPI
 from fastapi.testclient import TestClient
 from pydantic import BaseModel, Field
@@ -55,29 +55,16 @@ def test_required_str_missing(path: str, json: Union[dict[str, Any], None]):
     client = TestClient(app)
     response = client.post(path, json=json)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": IsOneOf(["body"], ["body", "p"]),
-                    "msg": "Field required",
-                    "input": IsOneOf(None, {}),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": IsOneOf(["body"], ["body", "p"]),
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": IsOneOf(["body"], ["body", "p"]),
+                "msg": "Field required",
+                "input": IsOneOf(None, {}),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -141,29 +128,16 @@ def test_required_alias_missing(path: str, json: Union[dict[str, Any], None]):
     client = TestClient(app)
     response = client.post(path, json=json)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": IsOneOf(["body", "p_alias"], ["body"]),
-                    "msg": "Field required",
-                    "input": IsOneOf(None, {}),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": IsOneOf(["body", "p_alias"], ["body"]),
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": IsOneOf(["body", "p_alias"], ["body"]),
+                "msg": "Field required",
+                "input": IsOneOf(None, {}),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -174,29 +148,16 @@ def test_required_alias_by_name(path: str):
     client = TestClient(app)
     response = client.post(path, json={"p": "hello"})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "p_alias"],
-                    "msg": "Field required",
-                    "input": IsOneOf(None, {"p": "hello"}),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": IsOneOf(["body", "p_alias"], ["body"]),
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "p_alias"],
+                "msg": "Field required",
+                "input": IsOneOf(None, {"p": "hello"}),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
index b2f7f9cef514aa1bf61b99f8d9f7b58b7babeb7c..6f381c8b8668be83cd606324925a85565a9e57cb 100644 (file)
@@ -1,7 +1,6 @@
 from typing import Annotated, Optional
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import Cookie, FastAPI
 from fastapi.testclient import TestClient
 from pydantic import BaseModel, Field
@@ -32,26 +31,15 @@ async def read_model_optional_str(p: Annotated[CookieModelOptionalStr, Cookie()]
 )
 def test_optional_str_schema(path: str):
     assert app.openapi()["paths"][path]["get"]["parameters"] == [
-        IsDict(
-            {
-                "required": False,
-                "schema": {
-                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                    "title": "P",
-                },
-                "name": "p",
-                "in": "cookie",
-            }
-        )
-        | IsDict(
-            # TODO: remove when deprecating Pydantic v1
-            {
-                "required": False,
-                "schema": {"title": "P", "type": "string"},
-                "name": "p",
-                "in": "cookie",
-            }
-        )
+        {
+            "required": False,
+            "schema": {
+                "anyOf": [{"type": "string"}, {"type": "null"}],
+                "title": "P",
+            },
+            "name": "p",
+            "in": "cookie",
+        }
     ]
 
 
@@ -104,26 +92,15 @@ async def read_model_optional_alias(p: Annotated[CookieModelOptionalAlias, Cooki
 )
 def test_optional_str_alias_schema(path: str):
     assert app.openapi()["paths"][path]["get"]["parameters"] == [
-        IsDict(
-            {
-                "required": False,
-                "schema": {
-                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                    "title": "P Alias",
-                },
-                "name": "p_alias",
-                "in": "cookie",
-            }
-        )
-        | IsDict(
-            # TODO: remove when deprecating Pydantic v1
-            {
-                "required": False,
-                "schema": {"title": "P Alias", "type": "string"},
-                "name": "p_alias",
-                "in": "cookie",
-            }
-        )
+        {
+            "required": False,
+            "schema": {
+                "anyOf": [{"type": "string"}, {"type": "null"}],
+                "title": "P Alias",
+            },
+            "name": "p_alias",
+            "in": "cookie",
+        }
     ]
 
 
index 58bb7af5b9a702105e3d95cb815c32296545fe80..3e877b3e3de6e36a9348997989b6e7fffedc0215 100644 (file)
@@ -1,7 +1,7 @@
 from typing import Annotated
 
 import pytest
-from dirty_equals import IsDict, IsOneOf
+from dirty_equals import IsOneOf
 from fastapi import Cookie, FastAPI
 from fastapi.testclient import TestClient
 from pydantic import BaseModel, Field
@@ -49,29 +49,16 @@ def test_required_str_missing(path: str):
     client = TestClient(app)
     response = client.get(path)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["cookie", "p"],
-                    "msg": "Field required",
-                    "input": IsOneOf(None, {}),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["cookie", "p"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["cookie", "p"],
+                "msg": "Field required",
+                "input": IsOneOf(None, {}),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -127,29 +114,16 @@ def test_required_alias_missing(path: str):
     client = TestClient(app)
     response = client.get(path)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["cookie", "p_alias"],
-                    "msg": "Field required",
-                    "input": IsOneOf(None, {}),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["cookie", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["cookie", "p_alias"],
+                "msg": "Field required",
+                "input": IsOneOf(None, {}),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -164,32 +138,19 @@ def test_required_alias_by_name(path: str):
     client.cookies.set("p", "hello")
     response = client.get(path)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["cookie", "p_alias"],
-                    "msg": "Field required",
-                    "input": IsOneOf(
-                        None,
-                        {"p": "hello"},
-                    ),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["cookie", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["cookie", "p_alias"],
+                "msg": "Field required",
+                "input": IsOneOf(
+                    None,
+                    {"p": "hello"},
+                ),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
index 90f36e5f7cf75ed4773bb0ac1a155c962363097c..f096532554f7d2de9ddf68949794dec489b62abe 100644 (file)
@@ -75,29 +75,16 @@ def test_list_missing(path: str):
     client = TestClient(app)
     response = client.post(path)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "p"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "p"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "p"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -182,29 +169,16 @@ def test_list_alias_missing(path: str):
     client = TestClient(app)
     response = client.post(path)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "p_alias"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "p_alias"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -218,29 +192,16 @@ def test_list_alias_by_name(path: str):
     client = TestClient(app)
     response = client.post(path, files=[("p", b"hello"), ("p", b"world")])
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "p_alias"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "p_alias"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
index 4e9564873cef1032b731676f435a5b68cafd6bc1..45ef7bdec4efcf4d9b7527f3a59cad1d02049db7 100644 (file)
@@ -1,7 +1,6 @@
 from typing import Annotated, Optional
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import FastAPI, File, UploadFile
 from fastapi.testclient import TestClient
 
@@ -36,21 +35,13 @@ def test_optional_schema(path: str):
 
     assert app.openapi()["components"]["schemas"][body_model_name] == {
         "properties": {
-            "p": (
-                IsDict(
-                    {
-                        "anyOf": [
-                            {"type": "string", "format": "binary"},
-                            {"type": "null"},
-                        ],
-                        "title": "P",
-                    }
-                )
-                | IsDict(
-                    # TODO: remove when deprecating Pydantic v1
-                    {"title": "P", "type": "string", "format": "binary"}
-                )
-            ),
+            "p": {
+                "anyOf": [
+                    {"type": "string", "format": "binary"},
+                    {"type": "null"},
+                ],
+                "title": "P",
+            }
         },
         "title": body_model_name,
         "type": "object",
@@ -116,21 +107,13 @@ def test_optional_alias_schema(path: str):
 
     assert app.openapi()["components"]["schemas"][body_model_name] == {
         "properties": {
-            "p_alias": (
-                IsDict(
-                    {
-                        "anyOf": [
-                            {"type": "string", "format": "binary"},
-                            {"type": "null"},
-                        ],
-                        "title": "P Alias",
-                    }
-                )
-                | IsDict(
-                    # TODO: remove when deprecating Pydantic v1
-                    {"title": "P Alias", "type": "string", "format": "binary"}
-                )
-            ),
+            "p_alias": {
+                "anyOf": [
+                    {"type": "string", "format": "binary"},
+                    {"type": "null"},
+                ],
+                "title": "P Alias",
+            }
         },
         "title": body_model_name,
         "type": "object",
@@ -215,21 +198,13 @@ def test_optional_validation_alias_schema(path: str):
 
     assert app.openapi()["components"]["schemas"][body_model_name] == {
         "properties": {
-            "p_val_alias": (
-                IsDict(
-                    {
-                        "anyOf": [
-                            {"type": "string", "format": "binary"},
-                            {"type": "null"},
-                        ],
-                        "title": "P Val Alias",
-                    }
-                )
-                | IsDict(
-                    # TODO: remove when deprecating Pydantic v1
-                    {"title": "P Val Alias", "type": "string", "format": "binary"}
-                )
-            ),
+            "p_val_alias": {
+                "anyOf": [
+                    {"type": "string", "format": "binary"},
+                    {"type": "null"},
+                ],
+                "title": "P Val Alias",
+            }
         },
         "title": body_model_name,
         "type": "object",
@@ -319,21 +294,13 @@ def test_optional_alias_and_validation_alias_schema(path: str):
 
     assert app.openapi()["components"]["schemas"][body_model_name] == {
         "properties": {
-            "p_val_alias": (
-                IsDict(
-                    {
-                        "anyOf": [
-                            {"type": "string", "format": "binary"},
-                            {"type": "null"},
-                        ],
-                        "title": "P Val Alias",
-                    }
-                )
-                | IsDict(
-                    # TODO: remove when deprecating Pydantic v1
-                    {"title": "P Val Alias", "type": "string", "format": "binary"}
-                )
-            ),
+            "p_val_alias": {
+                "anyOf": [
+                    {"type": "string", "format": "binary"},
+                    {"type": "null"},
+                ],
+                "title": "P Val Alias",
+            }
         },
         "title": body_model_name,
         "type": "object",
index e18f36e1520e3f4664a7e21fc79418d4c7cbd510..162fbe08ae195967ba6cb0bdb935408509c8b3c9 100644 (file)
@@ -1,7 +1,6 @@
 from typing import Annotated, Optional
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import FastAPI, File, UploadFile
 from fastapi.testclient import TestClient
 
@@ -38,28 +37,16 @@ def test_optional_list_schema(path: str):
 
     assert app.openapi()["components"]["schemas"][body_model_name] == {
         "properties": {
-            "p": (
-                IsDict(
+            "p": {
+                "anyOf": [
                     {
-                        "anyOf": [
-                            {
-                                "type": "array",
-                                "items": {"type": "string", "format": "binary"},
-                            },
-                            {"type": "null"},
-                        ],
-                        "title": "P",
-                    }
-                )
-                | IsDict(
-                    # TODO: remove when deprecating Pydantic v1
-                    {
-                        "title": "P",
                         "type": "array",
                         "items": {"type": "string", "format": "binary"},
                     },
-                )
-            ),
+                    {"type": "null"},
+                ],
+                "title": "P",
+            }
         },
         "title": body_model_name,
         "type": "object",
@@ -125,28 +112,16 @@ def test_optional_list_alias_schema(path: str):
 
     assert app.openapi()["components"]["schemas"][body_model_name] == {
         "properties": {
-            "p_alias": (
-                IsDict(
-                    {
-                        "anyOf": [
-                            {
-                                "type": "array",
-                                "items": {"type": "string", "format": "binary"},
-                            },
-                            {"type": "null"},
-                        ],
-                        "title": "P Alias",
-                    }
-                )
-                | IsDict(
-                    # TODO: remove when deprecating Pydantic v1
+            "p_alias": {
+                "anyOf": [
                     {
-                        "title": "P Alias",
                         "type": "array",
                         "items": {"type": "string", "format": "binary"},
-                    }
-                )
-            ),
+                    },
+                    {"type": "null"},
+                ],
+                "title": "P Alias",
+            }
         },
         "title": body_model_name,
         "type": "object",
@@ -228,28 +203,16 @@ def test_optional_validation_alias_schema(path: str):
 
     assert app.openapi()["components"]["schemas"][body_model_name] == {
         "properties": {
-            "p_val_alias": (
-                IsDict(
-                    {
-                        "anyOf": [
-                            {
-                                "type": "array",
-                                "items": {"type": "string", "format": "binary"},
-                            },
-                            {"type": "null"},
-                        ],
-                        "title": "P Val Alias",
-                    }
-                )
-                | IsDict(
-                    # TODO: remove when deprecating Pydantic v1
+            "p_val_alias": {
+                "anyOf": [
                     {
-                        "title": "P Val Alias",
                         "type": "array",
                         "items": {"type": "string", "format": "binary"},
-                    }
-                )
-            ),
+                    },
+                    {"type": "null"},
+                ],
+                "title": "P Val Alias",
+            }
         },
         "title": body_model_name,
         "type": "object",
@@ -336,28 +299,16 @@ def test_optional_list_alias_and_validation_alias_schema(path: str):
 
     assert app.openapi()["components"]["schemas"][body_model_name] == {
         "properties": {
-            "p_val_alias": (
-                IsDict(
-                    {
-                        "anyOf": [
-                            {
-                                "type": "array",
-                                "items": {"type": "string", "format": "binary"},
-                            },
-                            {"type": "null"},
-                        ],
-                        "title": "P Val Alias",
-                    }
-                )
-                | IsDict(
-                    # TODO: remove when deprecating Pydantic v1
+            "p_val_alias": {
+                "anyOf": [
                     {
-                        "title": "P Val Alias",
                         "type": "array",
                         "items": {"type": "string", "format": "binary"},
-                    }
-                )
-            ),
+                    },
+                    {"type": "null"},
+                ],
+                "title": "P Val Alias",
+            }
         },
         "title": body_model_name,
         "type": "object",
index 9783f4bceb2f4fad8d63962b646dbea3b91aa700..a0f9d23a6bec99c020122682a575ddf29de0553d 100644 (file)
@@ -1,7 +1,6 @@
 from typing import Annotated
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import FastAPI, File, UploadFile
 from fastapi.testclient import TestClient
 
@@ -55,29 +54,16 @@ def test_required_missing(path: str):
     client = TestClient(app)
     response = client.post(path)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "p"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "p"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "p"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -142,29 +128,16 @@ def test_required_alias_missing(path: str):
     client = TestClient(app)
     response = client.post(path)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "p_alias"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "p_alias"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -178,29 +151,16 @@ def test_required_alias_by_name(path: str):
     client = TestClient(app)
     response = client.post(path, files=[("p", b"hello")])
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "p_alias"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "p_alias"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
index 600dba4ae947efed5ad6c86c6632811c80a1ed8a..cfc42f523af465d8e065c094b9c65d84191e9978 100644 (file)
@@ -146,29 +146,16 @@ def test_required_list_alias_missing(path: str):
     client = TestClient(app)
     response = client.post(path)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "p_alias"],
-                    "msg": "Field required",
-                    "input": IsOneOf(None, {}),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "p_alias"],
+                "msg": "Field required",
+                "input": IsOneOf(None, {}),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -182,29 +169,16 @@ def test_required_list_alias_by_name(path: str):
     client = TestClient(app)
     response = client.post(path, data={"p": ["hello", "world"]})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "p_alias"],
-                    "msg": "Field required",
-                    "input": IsOneOf(None, {"p": ["hello", "world"]}),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "p_alias"],
+                "msg": "Field required",
+                "input": IsOneOf(None, {"p": ["hello", "world"]}),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
index 4552623f513f7e36fda3701d436574c09c16f525..6d1957a18c3a8bcff20bbfc5bb4ef65cebc4ef5b 100644 (file)
@@ -1,7 +1,6 @@
 from typing import Annotated, Optional
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import FastAPI, Form
 from fastapi.testclient import TestClient
 from pydantic import BaseModel, Field
@@ -38,30 +37,19 @@ def test_optional_list_str_schema(path: str):
     openapi = app.openapi()
     body_model_name = get_body_model_name(openapi, path)
 
-    assert app.openapi()["components"]["schemas"][body_model_name] == IsDict(
-        {
-            "properties": {
-                "p": {
-                    "anyOf": [
-                        {"items": {"type": "string"}, "type": "array"},
-                        {"type": "null"},
-                    ],
-                    "title": "P",
-                },
+    assert app.openapi()["components"]["schemas"][body_model_name] == {
+        "properties": {
+            "p": {
+                "anyOf": [
+                    {"items": {"type": "string"}, "type": "array"},
+                    {"type": "null"},
+                ],
+                "title": "P",
             },
-            "title": body_model_name,
-            "type": "object",
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "properties": {
-                "p": {"items": {"type": "string"}, "type": "array", "title": "P"},
-            },
-            "title": body_model_name,
-            "type": "object",
-        }
-    )
+        },
+        "title": body_model_name,
+        "type": "object",
+    }
 
 
 @pytest.mark.parametrize(
@@ -119,34 +107,19 @@ def test_optional_list_str_alias_schema(path: str):
     openapi = app.openapi()
     body_model_name = get_body_model_name(openapi, path)
 
-    assert app.openapi()["components"]["schemas"][body_model_name] == IsDict(
-        {
-            "properties": {
-                "p_alias": {
-                    "anyOf": [
-                        {"items": {"type": "string"}, "type": "array"},
-                        {"type": "null"},
-                    ],
-                    "title": "P Alias",
-                },
+    assert app.openapi()["components"]["schemas"][body_model_name] == {
+        "properties": {
+            "p_alias": {
+                "anyOf": [
+                    {"items": {"type": "string"}, "type": "array"},
+                    {"type": "null"},
+                ],
+                "title": "P Alias",
             },
-            "title": body_model_name,
-            "type": "object",
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "properties": {
-                "p_alias": {
-                    "items": {"type": "string"},
-                    "type": "array",
-                    "title": "P Alias",
-                },
-            },
-            "title": body_model_name,
-            "type": "object",
-        }
-    )
+        },
+        "title": body_model_name,
+        "type": "object",
+    }
 
 
 @pytest.mark.parametrize(
@@ -217,34 +190,19 @@ def test_optional_list_validation_alias_schema(path: str):
     openapi = app.openapi()
     body_model_name = get_body_model_name(openapi, path)
 
-    assert app.openapi()["components"]["schemas"][body_model_name] == IsDict(
-        {
-            "properties": {
-                "p_val_alias": {
-                    "anyOf": [
-                        {"items": {"type": "string"}, "type": "array"},
-                        {"type": "null"},
-                    ],
-                    "title": "P Val Alias",
-                },
+    assert app.openapi()["components"]["schemas"][body_model_name] == {
+        "properties": {
+            "p_val_alias": {
+                "anyOf": [
+                    {"items": {"type": "string"}, "type": "array"},
+                    {"type": "null"},
+                ],
+                "title": "P Val Alias",
             },
-            "title": body_model_name,
-            "type": "object",
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "properties": {
-                "p_val_alias": {
-                    "items": {"type": "string"},
-                    "type": "array",
-                    "title": "P Val Alias",
-                },
-            },
-            "title": body_model_name,
-            "type": "object",
-        }
-    )
+        },
+        "title": body_model_name,
+        "type": "object",
+    }
 
 
 @pytest.mark.parametrize(
@@ -326,34 +284,19 @@ def test_optional_list_alias_and_validation_alias_schema(path: str):
     openapi = app.openapi()
     body_model_name = get_body_model_name(openapi, path)
 
-    assert app.openapi()["components"]["schemas"][body_model_name] == IsDict(
-        {
-            "properties": {
-                "p_val_alias": {
-                    "anyOf": [
-                        {"items": {"type": "string"}, "type": "array"},
-                        {"type": "null"},
-                    ],
-                    "title": "P Val Alias",
-                },
+    assert app.openapi()["components"]["schemas"][body_model_name] == {
+        "properties": {
+            "p_val_alias": {
+                "anyOf": [
+                    {"items": {"type": "string"}, "type": "array"},
+                    {"type": "null"},
+                ],
+                "title": "P Val Alias",
             },
-            "title": body_model_name,
-            "type": "object",
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "properties": {
-                "p_val_alias": {
-                    "items": {"type": "string"},
-                    "type": "array",
-                    "title": "P Val Alias",
-                },
-            },
-            "title": body_model_name,
-            "type": "object",
-        }
-    )
+        },
+        "title": body_model_name,
+        "type": "object",
+    }
 
 
 @pytest.mark.parametrize(
index 1b08299046a310ef18af1b95c9c47cc542572a25..810e83caa38c7fe4ab99cac7d547111b17886260 100644 (file)
@@ -1,7 +1,6 @@
 from typing import Annotated, Optional
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import FastAPI, Form
 from fastapi.testclient import TestClient
 from pydantic import BaseModel, Field
@@ -36,27 +35,16 @@ def test_optional_str_schema(path: str):
     openapi = app.openapi()
     body_model_name = get_body_model_name(openapi, path)
 
-    assert app.openapi()["components"]["schemas"][body_model_name] == IsDict(
-        {
-            "properties": {
-                "p": {
-                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                    "title": "P",
-                },
+    assert app.openapi()["components"]["schemas"][body_model_name] == {
+        "properties": {
+            "p": {
+                "anyOf": [{"type": "string"}, {"type": "null"}],
+                "title": "P",
             },
-            "title": body_model_name,
-            "type": "object",
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "properties": {
-                "p": {"type": "string", "title": "P"},
-            },
-            "title": body_model_name,
-            "type": "object",
-        }
-    )
+        },
+        "title": body_model_name,
+        "type": "object",
+    }
 
 
 @pytest.mark.parametrize(
@@ -112,27 +100,16 @@ def test_optional_str_alias_schema(path: str):
     openapi = app.openapi()
     body_model_name = get_body_model_name(openapi, path)
 
-    assert app.openapi()["components"]["schemas"][body_model_name] == IsDict(
-        {
-            "properties": {
-                "p_alias": {
-                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                    "title": "P Alias",
-                },
-            },
-            "title": body_model_name,
-            "type": "object",
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "properties": {
-                "p_alias": {"type": "string", "title": "P Alias"},
+    assert app.openapi()["components"]["schemas"][body_model_name] == {
+        "properties": {
+            "p_alias": {
+                "anyOf": [{"type": "string"}, {"type": "null"}],
+                "title": "P Alias",
             },
-            "title": body_model_name,
-            "type": "object",
-        }
-    )
+        },
+        "title": body_model_name,
+        "type": "object",
+    }
 
 
 @pytest.mark.parametrize(
@@ -200,27 +177,16 @@ def test_optional_validation_alias_schema(path: str):
     openapi = app.openapi()
     body_model_name = get_body_model_name(openapi, path)
 
-    assert app.openapi()["components"]["schemas"][body_model_name] == IsDict(
-        {
-            "properties": {
-                "p_val_alias": {
-                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                    "title": "P Val Alias",
-                },
+    assert app.openapi()["components"]["schemas"][body_model_name] == {
+        "properties": {
+            "p_val_alias": {
+                "anyOf": [{"type": "string"}, {"type": "null"}],
+                "title": "P Val Alias",
             },
-            "title": body_model_name,
-            "type": "object",
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "properties": {
-                "p_val_alias": {"type": "string", "title": "P Val Alias"},
-            },
-            "title": body_model_name,
-            "type": "object",
-        }
-    )
+        },
+        "title": body_model_name,
+        "type": "object",
+    }
 
 
 @pytest.mark.parametrize(
@@ -303,27 +269,16 @@ def test_optional_alias_and_validation_alias_schema(path: str):
     openapi = app.openapi()
     body_model_name = get_body_model_name(openapi, path)
 
-    assert app.openapi()["components"]["schemas"][body_model_name] == IsDict(
-        {
-            "properties": {
-                "p_val_alias": {
-                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                    "title": "P Val Alias",
-                },
-            },
-            "title": body_model_name,
-            "type": "object",
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "properties": {
-                "p_val_alias": {"type": "string", "title": "P Val Alias"},
+    assert app.openapi()["components"]["schemas"][body_model_name] == {
+        "properties": {
+            "p_val_alias": {
+                "anyOf": [{"type": "string"}, {"type": "null"}],
+                "title": "P Val Alias",
             },
-            "title": body_model_name,
-            "type": "object",
-        }
-    )
+        },
+        "title": body_model_name,
+        "type": "object",
+    }
 
 
 @pytest.mark.parametrize(
index 1d2431b3334446bd92ff24d0516c23ad4ced0732..7c9523b308338995d92b064847f9a6fe7edb7b29 100644 (file)
@@ -1,7 +1,7 @@
 from typing import Annotated
 
 import pytest
-from dirty_equals import IsDict, IsOneOf
+from dirty_equals import IsOneOf
 from fastapi import FastAPI, Form
 from fastapi.testclient import TestClient
 from pydantic import BaseModel, Field
@@ -54,29 +54,16 @@ def test_required_str_missing(path: str):
     client = TestClient(app)
     response = client.post(path)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "p"],
-                    "msg": "Field required",
-                    "input": IsOneOf(None, {}),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "p"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "p"],
+                "msg": "Field required",
+                "input": IsOneOf(None, {}),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -137,29 +124,16 @@ def test_required_alias_missing(path: str):
     client = TestClient(app)
     response = client.post(path)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "p_alias"],
-                    "msg": "Field required",
-                    "input": IsOneOf(None, {}),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "p_alias"],
+                "msg": "Field required",
+                "input": IsOneOf(None, {}),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -170,29 +144,16 @@ def test_required_alias_by_name(path: str):
     client = TestClient(app)
     response = client.post(path, data={"p": "hello"})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "p_alias"],
-                    "msg": "Field required",
-                    "input": IsOneOf(None, {"p": "hello"}),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "p_alias"],
+                "msg": "Field required",
+                "input": IsOneOf(None, {"p": "hello"}),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
index 2eba17559e67eb6b1d871192c0149ddc2339d84b..65510094af597d64952eb3181927f3fc4b212684 100644 (file)
@@ -135,29 +135,16 @@ def test_required_list_alias_missing(path: str):
     client = TestClient(app)
     response = client.get(path)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["header", "p_alias"],
-                    "msg": "Field required",
-                    "input": AnyThing,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["header", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["header", "p_alias"],
+                "msg": "Field required",
+                "input": AnyThing,
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -171,29 +158,16 @@ def test_required_list_alias_by_name(path: str):
     client = TestClient(app)
     response = client.get(path, headers=[("p", "hello"), ("p", "world")])
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["header", "p_alias"],
-                    "msg": "Field required",
-                    "input": IsOneOf(None, IsPartialDict({"p": ["hello", "world"]})),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["header", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["header", "p_alias"],
+                "msg": "Field required",
+                "input": IsOneOf(None, IsPartialDict({"p": ["hello", "world"]})),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
index cd6167a1833dd3e8b8b5e29cb53e09bb76e9ccbd..5dd4ea9ade19ef2d6929972c5a70f228c4e82c85 100644 (file)
@@ -1,7 +1,6 @@
 from typing import Annotated, Optional
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import FastAPI, Header
 from fastapi.testclient import TestClient
 from pydantic import BaseModel, Field
@@ -36,29 +35,18 @@ async def read_model_optional_list_str(
 )
 def test_optional_list_str_schema(path: str):
     assert app.openapi()["paths"][path]["get"]["parameters"] == [
-        IsDict(
-            {
-                "required": False,
-                "schema": {
-                    "anyOf": [
-                        {"items": {"type": "string"}, "type": "array"},
-                        {"type": "null"},
-                    ],
-                    "title": "P",
-                },
-                "name": "p",
-                "in": "header",
-            }
-        )
-        | IsDict(
-            # TODO: remove when deprecating Pydantic v1
-            {
-                "required": False,
-                "schema": {"items": {"type": "string"}, "type": "array", "title": "P"},
-                "name": "p",
-                "in": "header",
-            }
-        )
+        {
+            "required": False,
+            "schema": {
+                "anyOf": [
+                    {"items": {"type": "string"}, "type": "array"},
+                    {"type": "null"},
+                ],
+                "title": "P",
+            },
+            "name": "p",
+            "in": "header",
+        }
     ]
 
 
@@ -112,33 +100,18 @@ async def read_model_optional_list_alias(
 )
 def test_optional_list_str_alias_schema(path: str):
     assert app.openapi()["paths"][path]["get"]["parameters"] == [
-        IsDict(
-            {
-                "required": False,
-                "schema": {
-                    "anyOf": [
-                        {"items": {"type": "string"}, "type": "array"},
-                        {"type": "null"},
-                    ],
-                    "title": "P Alias",
-                },
-                "name": "p_alias",
-                "in": "header",
-            }
-        )
-        | IsDict(
-            # TODO: remove when deprecating Pydantic v1
-            {
-                "required": False,
-                "schema": {
-                    "items": {"type": "string"},
-                    "type": "array",
-                    "title": "P Alias",
-                },
-                "name": "p_alias",
-                "in": "header",
-            }
-        )
+        {
+            "required": False,
+            "schema": {
+                "anyOf": [
+                    {"items": {"type": "string"}, "type": "array"},
+                    {"type": "null"},
+                ],
+                "title": "P Alias",
+            },
+            "name": "p_alias",
+            "in": "header",
+        }
     ]
 
 
index d4f25cc1e7ddb8208fb78998eccfd6f345272458..0bd0eddc1b1089bb2f44ade460e268bfdf07be9d 100644 (file)
@@ -1,7 +1,6 @@
 from typing import Annotated, Optional
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import FastAPI, Header
 from fastapi.testclient import TestClient
 from pydantic import BaseModel, Field
@@ -32,26 +31,15 @@ async def read_model_optional_str(p: Annotated[HeaderModelOptionalStr, Header()]
 )
 def test_optional_str_schema(path: str):
     assert app.openapi()["paths"][path]["get"]["parameters"] == [
-        IsDict(
-            {
-                "required": False,
-                "schema": {
-                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                    "title": "P",
-                },
-                "name": "p",
-                "in": "header",
-            }
-        )
-        | IsDict(
-            # TODO: remove when deprecating Pydantic v1
-            {
-                "required": False,
-                "schema": {"title": "P", "type": "string"},
-                "name": "p",
-                "in": "header",
-            }
-        )
+        {
+            "required": False,
+            "schema": {
+                "anyOf": [{"type": "string"}, {"type": "null"}],
+                "title": "P",
+            },
+            "name": "p",
+            "in": "header",
+        }
     ]
 
 
@@ -103,26 +91,15 @@ async def read_model_optional_alias(p: Annotated[HeaderModelOptionalAlias, Heade
 )
 def test_optional_str_alias_schema(path: str):
     assert app.openapi()["paths"][path]["get"]["parameters"] == [
-        IsDict(
-            {
-                "required": False,
-                "schema": {
-                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                    "title": "P Alias",
-                },
-                "name": "p_alias",
-                "in": "header",
-            }
-        )
-        | IsDict(
-            # TODO: remove when deprecating Pydantic v1
-            {
-                "required": False,
-                "schema": {"title": "P Alias", "type": "string"},
-                "name": "p_alias",
-                "in": "header",
-            }
-        )
+        {
+            "required": False,
+            "schema": {
+                "anyOf": [{"type": "string"}, {"type": "null"}],
+                "title": "P Alias",
+            },
+            "name": "p_alias",
+            "in": "header",
+        }
     ]
 
 
index 85bb43d5a872a31df33da295a9472be5bce863dc..20dd296570eede53e159dde17220a1c589dd916f 100644 (file)
@@ -1,7 +1,7 @@
 from typing import Annotated
 
 import pytest
-from dirty_equals import AnyThing, IsDict, IsOneOf, IsPartialDict
+from dirty_equals import AnyThing, IsOneOf, IsPartialDict
 from fastapi import FastAPI, Header
 from fastapi.testclient import TestClient
 from pydantic import BaseModel, Field
@@ -49,29 +49,16 @@ def test_required_str_missing(path: str):
     client = TestClient(app)
     response = client.get(path)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["header", "p"],
-                    "msg": "Field required",
-                    "input": AnyThing,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["header", "p"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["header", "p"],
+                "msg": "Field required",
+                "input": AnyThing,
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -126,29 +113,16 @@ def test_required_alias_missing(path: str):
     client = TestClient(app)
     response = client.get(path)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["header", "p_alias"],
-                    "msg": "Field required",
-                    "input": AnyThing,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["header", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["header", "p_alias"],
+                "msg": "Field required",
+                "input": AnyThing,
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -162,29 +136,16 @@ def test_required_alias_by_name(path: str):
     client = TestClient(app)
     response = client.get(path, headers={"p": "hello"})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["header", "p_alias"],
-                    "msg": "Field required",
-                    "input": IsOneOf(None, IsPartialDict({"p": "hello"})),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["header", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["header", "p_alias"],
+                "msg": "Field required",
+                "input": IsOneOf(None, IsPartialDict({"p": "hello"})),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
index dc21a8500623e429398e51d8cc239ea35ac74c6a..ed2ea6c809f0c8b89139faea5a46874b303b350c 100644 (file)
@@ -135,29 +135,16 @@ def test_required_list_alias_missing(path: str):
     client = TestClient(app)
     response = client.get(path)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "p_alias"],
-                    "msg": "Field required",
-                    "input": IsOneOf(None, {}),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "p_alias"],
+                "msg": "Field required",
+                "input": IsOneOf(None, {}),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -171,29 +158,16 @@ def test_required_list_alias_by_name(path: str):
     client = TestClient(app)
     response = client.get(f"{path}?p=hello&p=world")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "p_alias"],
-                    "msg": "Field required",
-                    "input": IsOneOf(None, {"p": ["hello", "world"]}),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "p_alias"],
+                "msg": "Field required",
+                "input": IsOneOf(None, {"p": ["hello", "world"]}),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
index 2a8f63a36a1192105991e2c9cffeb41485ccaf3a..351e03a7138dd4723ea4a8bd0d15dbd332004717 100644 (file)
@@ -1,7 +1,6 @@
 from typing import Annotated, Optional
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import FastAPI, Query
 from fastapi.testclient import TestClient
 from pydantic import BaseModel, Field
@@ -36,29 +35,18 @@ async def read_model_optional_list_str(
 )
 def test_optional_list_str_schema(path: str):
     assert app.openapi()["paths"][path]["get"]["parameters"] == [
-        IsDict(
-            {
-                "required": False,
-                "schema": {
-                    "anyOf": [
-                        {"items": {"type": "string"}, "type": "array"},
-                        {"type": "null"},
-                    ],
-                    "title": "P",
-                },
-                "name": "p",
-                "in": "query",
-            }
-        )
-        | IsDict(
-            # TODO: remove when deprecating Pydantic v1
-            {
-                "required": False,
-                "schema": {"items": {"type": "string"}, "type": "array", "title": "P"},
-                "name": "p",
-                "in": "query",
-            }
-        )
+        {
+            "required": False,
+            "schema": {
+                "anyOf": [
+                    {"items": {"type": "string"}, "type": "array"},
+                    {"type": "null"},
+                ],
+                "title": "P",
+            },
+            "name": "p",
+            "in": "query",
+        }
     ]
 
 
@@ -112,33 +100,18 @@ async def read_model_optional_list_alias(
 )
 def test_optional_list_str_alias_schema(path: str):
     assert app.openapi()["paths"][path]["get"]["parameters"] == [
-        IsDict(
-            {
-                "required": False,
-                "schema": {
-                    "anyOf": [
-                        {"items": {"type": "string"}, "type": "array"},
-                        {"type": "null"},
-                    ],
-                    "title": "P Alias",
-                },
-                "name": "p_alias",
-                "in": "query",
-            }
-        )
-        | IsDict(
-            # TODO: remove when deprecating Pydantic v1
-            {
-                "required": False,
-                "schema": {
-                    "items": {"type": "string"},
-                    "type": "array",
-                    "title": "P Alias",
-                },
-                "name": "p_alias",
-                "in": "query",
-            }
-        )
+        {
+            "required": False,
+            "schema": {
+                "anyOf": [
+                    {"items": {"type": "string"}, "type": "array"},
+                    {"type": "null"},
+                ],
+                "title": "P Alias",
+            },
+            "name": "p_alias",
+            "in": "query",
+        }
     ]
 
 
index c6a70bc28382c09324f9bc228e42ceae679dc115..12e1b465a76cde68818dc68331edaec863ed7a8b 100644 (file)
@@ -1,7 +1,6 @@
 from typing import Annotated, Optional
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import FastAPI, Query
 from fastapi.testclient import TestClient
 from pydantic import BaseModel, Field
@@ -32,26 +31,15 @@ async def read_model_optional_str(p: Annotated[QueryModelOptionalStr, Query()]):
 )
 def test_optional_str_schema(path: str):
     assert app.openapi()["paths"][path]["get"]["parameters"] == [
-        IsDict(
-            {
-                "required": False,
-                "schema": {
-                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                    "title": "P",
-                },
-                "name": "p",
-                "in": "query",
-            }
-        )
-        | IsDict(
-            # TODO: remove when deprecating Pydantic v1
-            {
-                "required": False,
-                "schema": {"title": "P", "type": "string"},
-                "name": "p",
-                "in": "query",
-            }
-        )
+        {
+            "required": False,
+            "schema": {
+                "anyOf": [{"type": "string"}, {"type": "null"}],
+                "title": "P",
+            },
+            "name": "p",
+            "in": "query",
+        }
     ]
 
 
@@ -103,26 +91,15 @@ async def read_model_optional_alias(p: Annotated[QueryModelOptionalAlias, Query(
 )
 def test_optional_str_alias_schema(path: str):
     assert app.openapi()["paths"][path]["get"]["parameters"] == [
-        IsDict(
-            {
-                "required": False,
-                "schema": {
-                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                    "title": "P Alias",
-                },
-                "name": "p_alias",
-                "in": "query",
-            }
-        )
-        | IsDict(
-            # TODO: remove when deprecating Pydantic v1
-            {
-                "required": False,
-                "schema": {"title": "P Alias", "type": "string"},
-                "name": "p_alias",
-                "in": "query",
-            }
-        )
+        {
+            "required": False,
+            "schema": {
+                "anyOf": [{"type": "string"}, {"type": "null"}],
+                "title": "P Alias",
+            },
+            "name": "p_alias",
+            "in": "query",
+        }
     ]
 
 
index 2ef1b0373da4cb2cf11f97b60fe99a2885a3aeec..9e7b961453e1abc678a2a12770323a6b41c8e3fe 100644 (file)
@@ -1,7 +1,7 @@
 from typing import Annotated
 
 import pytest
-from dirty_equals import IsDict, IsOneOf
+from dirty_equals import IsOneOf
 from fastapi import FastAPI, Query
 from fastapi.testclient import TestClient
 from pydantic import BaseModel, Field
@@ -49,29 +49,16 @@ def test_required_str_missing(path: str):
     client = TestClient(app)
     response = client.get(path)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "p"],
-                    "msg": "Field required",
-                    "input": IsOneOf(None, {}),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "p"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "p"],
+                "msg": "Field required",
+                "input": IsOneOf(None, {}),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -126,29 +113,16 @@ def test_required_alias_missing(path: str):
     client = TestClient(app)
     response = client.get(path)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "p_alias"],
-                    "msg": "Field required",
-                    "input": IsOneOf(None, {}),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "p_alias"],
+                "msg": "Field required",
+                "input": IsOneOf(None, {}),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -162,32 +136,19 @@ def test_required_alias_by_name(path: str):
     client = TestClient(app)
     response = client.get(f"{path}?p=hello")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "p_alias"],
-                    "msg": "Field required",
-                    "input": IsOneOf(
-                        None,
-                        {"p": "hello"},
-                    ),
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "p_alias"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "p_alias"],
+                "msg": "Field required",
+                "input": IsOneOf(
+                    None,
+                    {"p": "hello"},
+                ),
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
index 8f5195ba11001f34ed5ce37438c36a045a29cd81..ac8999c90a1a6b38f6f9366ca202297faf568a09 100644 (file)
@@ -1,7 +1,6 @@
 from typing import Union
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import Body, Cookie, FastAPI, Header, Path, Query
 from fastapi.exceptions import FastAPIDeprecationWarning
 from fastapi.testclient import TestClient
@@ -336,28 +335,13 @@ def test_openapi_schema():
                     "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": IsDict(
-                                    {
-                                        "$ref": "#/components/schemas/Item",
-                                        "examples": [
-                                            {"data": "Data in Body examples, example1"},
-                                            {"data": "Data in Body examples, example2"},
-                                        ],
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove this when deprecating Pydantic v1
-                                    {
-                                        "allOf": [
-                                            {"$ref": "#/components/schemas/Item"}
-                                        ],
-                                        "title": "Item",
-                                        "examples": [
-                                            {"data": "Data in Body examples, example1"},
-                                            {"data": "Data in Body examples, example2"},
-                                        ],
-                                    }
-                                )
+                                "schema": {
+                                    "$ref": "#/components/schemas/Item",
+                                    "examples": [
+                                        {"data": "Data in Body examples, example1"},
+                                        {"data": "Data in Body examples, example2"},
+                                    ],
+                                }
                             }
                         },
                         "required": True,
@@ -387,28 +371,13 @@ def test_openapi_schema():
                     "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": IsDict(
-                                    {
-                                        "$ref": "#/components/schemas/Item",
-                                        "examples": [
-                                            {"data": "examples example_examples 1"},
-                                            {"data": "examples example_examples 2"},
-                                        ],
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove this when deprecating Pydantic v1
-                                    {
-                                        "allOf": [
-                                            {"$ref": "#/components/schemas/Item"}
-                                        ],
-                                        "title": "Item",
-                                        "examples": [
-                                            {"data": "examples example_examples 1"},
-                                            {"data": "examples example_examples 2"},
-                                        ],
-                                    },
-                                ),
+                                "schema": {
+                                    "$ref": "#/components/schemas/Item",
+                                    "examples": [
+                                        {"data": "examples example_examples 1"},
+                                        {"data": "examples example_examples 2"},
+                                    ],
+                                },
                                 "example": {"data": "Overridden example"},
                             }
                         },
@@ -539,16 +508,10 @@ def test_openapi_schema():
                     "parameters": [
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Data",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: Remove this when deprecating Pydantic v1
-                                {"title": "Data", "type": "string"}
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "Data",
+                            },
                             "example": "query1",
                             "name": "data",
                             "in": "query",
@@ -579,21 +542,11 @@ def test_openapi_schema():
                     "parameters": [
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Data",
-                                    "examples": ["query1", "query2"],
-                                }
-                            )
-                            | IsDict(
-                                # TODO: Remove this when deprecating Pydantic v1
-                                {
-                                    "type": "string",
-                                    "title": "Data",
-                                    "examples": ["query1", "query2"],
-                                }
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "Data",
+                                "examples": ["query1", "query2"],
+                            },
                             "name": "data",
                             "in": "query",
                         }
@@ -623,21 +576,11 @@ def test_openapi_schema():
                     "parameters": [
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Data",
-                                    "examples": ["query1", "query2"],
-                                }
-                            )
-                            | IsDict(
-                                # TODO: Remove this when deprecating Pydantic v1
-                                {
-                                    "type": "string",
-                                    "title": "Data",
-                                    "examples": ["query1", "query2"],
-                                }
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "Data",
+                                "examples": ["query1", "query2"],
+                            },
                             "example": "query_overridden",
                             "name": "data",
                             "in": "query",
@@ -668,16 +611,10 @@ def test_openapi_schema():
                     "parameters": [
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Data",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: Remove this when deprecating Pydantic v1
-                                {"title": "Data", "type": "string"}
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "Data",
+                            },
                             "example": "header1",
                             "name": "data",
                             "in": "header",
@@ -708,21 +645,11 @@ def test_openapi_schema():
                     "parameters": [
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Data",
-                                    "examples": ["header1", "header2"],
-                                }
-                            )
-                            | IsDict(
-                                # TODO: Remove this when deprecating Pydantic v1
-                                {
-                                    "type": "string",
-                                    "title": "Data",
-                                    "examples": ["header1", "header2"],
-                                }
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "Data",
+                                "examples": ["header1", "header2"],
+                            },
                             "name": "data",
                             "in": "header",
                         }
@@ -752,21 +679,11 @@ def test_openapi_schema():
                     "parameters": [
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Data",
-                                    "examples": ["header1", "header2"],
-                                }
-                            )
-                            | IsDict(
-                                # TODO: Remove this when deprecating Pydantic v1
-                                {
-                                    "title": "Data",
-                                    "type": "string",
-                                    "examples": ["header1", "header2"],
-                                }
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "Data",
+                                "examples": ["header1", "header2"],
+                            },
                             "example": "header_overridden",
                             "name": "data",
                             "in": "header",
@@ -797,16 +714,10 @@ def test_openapi_schema():
                     "parameters": [
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Data",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: Remove this when deprecating Pydantic v1
-                                {"title": "Data", "type": "string"}
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "Data",
+                            },
                             "example": "cookie1",
                             "name": "data",
                             "in": "cookie",
@@ -837,21 +748,11 @@ def test_openapi_schema():
                     "parameters": [
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Data",
-                                    "examples": ["cookie1", "cookie2"],
-                                }
-                            )
-                            | IsDict(
-                                # TODO: Remove this when deprecating Pydantic v1
-                                {
-                                    "title": "Data",
-                                    "type": "string",
-                                    "examples": ["cookie1", "cookie2"],
-                                }
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "Data",
+                                "examples": ["cookie1", "cookie2"],
+                            },
                             "name": "data",
                             "in": "cookie",
                         }
@@ -881,21 +782,11 @@ def test_openapi_schema():
                     "parameters": [
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Data",
-                                    "examples": ["cookie1", "cookie2"],
-                                }
-                            )
-                            | IsDict(
-                                # TODO: Remove this when deprecating Pydantic v1
-                                {
-                                    "title": "Data",
-                                    "type": "string",
-                                    "examples": ["cookie1", "cookie2"],
-                                }
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "Data",
+                                "examples": ["cookie1", "cookie2"],
+                            },
                             "example": "cookie_overridden",
                             "name": "data",
                             "in": "cookie",
index 804e4152dbd2e73ea092b09c621da62c790ec84d..7ad9369956c2f8d63fbb1690fb6b6b7c223c6e16 100644 (file)
@@ -1,5 +1,4 @@
 import pytest
-from dirty_equals import IsDict
 from fastapi import Depends, FastAPI, Security
 from fastapi.security import OAuth2, OAuth2PasswordRequestFormStrict
 from fastapi.testclient import TestClient
@@ -64,79 +63,43 @@ def test_security_oauth2_password_bearer_no_header():
 def test_strict_login_no_data():
     response = client.post("/login")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "grant_type"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "username"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "password"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "grant_type"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "username"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "password"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "grant_type"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "username"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "password"],
+                "msg": "Field required",
+                "input": None,
+            },
+        ]
+    }
 
 
 def test_strict_login_no_grant_type():
     response = client.post("/login", data={"username": "johndoe", "password": "secret"})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "grant_type"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "grant_type"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "grant_type"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -153,31 +116,17 @@ def test_strict_login_incorrect_grant_type(grant_type: str):
         data={"username": "johndoe", "password": "secret", "grant_type": grant_type},
     )
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "string_pattern_mismatch",
-                    "loc": ["body", "grant_type"],
-                    "msg": "String should match pattern '^password$'",
-                    "input": grant_type,
-                    "ctx": {"pattern": "^password$"},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "grant_type"],
-                    "msg": 'string does not match regex "^password$"',
-                    "type": "value_error.str.regex",
-                    "ctx": {"pattern": "^password$"},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "string_pattern_mismatch",
+                "loc": ["body", "grant_type"],
+                "msg": "String should match pattern '^password$'",
+                "input": grant_type,
+                "ctx": {"pattern": "^password$"},
+            }
+        ]
+    }
 
 
 def test_strict_login_correct_grant_type():
@@ -264,26 +213,14 @@ def test_openapi_schema():
                         "username": {"title": "Username", "type": "string"},
                         "password": {"title": "Password", "type": "string"},
                         "scope": {"title": "Scope", "type": "string", "default": ""},
-                        "client_id": IsDict(
-                            {
-                                "title": "Client Id",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Client Id", "type": "string"}
-                        ),
-                        "client_secret": IsDict(
-                            {
-                                "title": "Client Secret",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Client Secret", "type": "string"}
-                        ),
+                        "client_id": {
+                            "title": "Client Id",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
+                        },
+                        "client_secret": {
+                            "title": "Client Secret",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
+                        },
                     },
                 },
                 "ValidationError": {
index 046ac57637dfcea79c74dc045f90c8ade16ac5af..57c16058af8aedec97699ad1ebd83340ae203b39 100644 (file)
@@ -1,7 +1,6 @@
 from typing import Optional
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import Depends, FastAPI, Security
 from fastapi.security import OAuth2, OAuth2PasswordRequestFormStrict
 from fastapi.testclient import TestClient
@@ -67,79 +66,43 @@ def test_security_oauth2_password_bearer_no_header():
 def test_strict_login_no_data():
     response = client.post("/login")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "grant_type"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "username"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "password"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "grant_type"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "username"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "password"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "grant_type"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "username"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "password"],
+                "msg": "Field required",
+                "input": None,
+            },
+        ]
+    }
 
 
 def test_strict_login_no_grant_type():
     response = client.post("/login", data={"username": "johndoe", "password": "secret"})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "grant_type"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "grant_type"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "grant_type"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -156,31 +119,17 @@ def test_strict_login_incorrect_grant_type(grant_type: str):
         data={"username": "johndoe", "password": "secret", "grant_type": grant_type},
     )
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "string_pattern_mismatch",
-                    "loc": ["body", "grant_type"],
-                    "msg": "String should match pattern '^password$'",
-                    "input": grant_type,
-                    "ctx": {"pattern": "^password$"},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "grant_type"],
-                    "msg": 'string does not match regex "^password$"',
-                    "type": "value_error.str.regex",
-                    "ctx": {"pattern": "^password$"},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "string_pattern_mismatch",
+                "loc": ["body", "grant_type"],
+                "msg": "String should match pattern '^password$'",
+                "input": grant_type,
+                "ctx": {"pattern": "^password$"},
+            }
+        ]
+    }
 
 
 def test_strict_login_correct_data():
@@ -267,26 +216,14 @@ def test_openapi_schema():
                         "username": {"title": "Username", "type": "string"},
                         "password": {"title": "Password", "type": "string"},
                         "scope": {"title": "Scope", "type": "string", "default": ""},
-                        "client_id": IsDict(
-                            {
-                                "title": "Client Id",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Client Id", "type": "string"}
-                        ),
-                        "client_secret": IsDict(
-                            {
-                                "title": "Client Secret",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Client Secret", "type": "string"}
-                        ),
+                        "client_id": {
+                            "title": "Client Id",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
+                        },
+                        "client_secret": {
+                            "title": "Client Secret",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
+                        },
                     },
                 },
                 "ValidationError": {
index 629cddca2f1a1c1abb854b1b8c580da6788eebea..60c6c242e059885d5fed75b9bd7f092e588b2109 100644 (file)
@@ -1,7 +1,6 @@
 from typing import Optional
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import Depends, FastAPI, Security
 from fastapi.security import OAuth2, OAuth2PasswordRequestFormStrict
 from fastapi.testclient import TestClient
@@ -68,79 +67,43 @@ def test_security_oauth2_password_bearer_no_header():
 def test_strict_login_None():
     response = client.post("/login", data=None)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "grant_type"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "username"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "password"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "grant_type"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "username"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "password"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "grant_type"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "username"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "password"],
+                "msg": "Field required",
+                "input": None,
+            },
+        ]
+    }
 
 
 def test_strict_login_no_grant_type():
     response = client.post("/login", data={"username": "johndoe", "password": "secret"})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "grant_type"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "grant_type"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "grant_type"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 @pytest.mark.parametrize(
@@ -157,31 +120,17 @@ def test_strict_login_incorrect_grant_type(grant_type: str):
         data={"username": "johndoe", "password": "secret", "grant_type": grant_type},
     )
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "string_pattern_mismatch",
-                    "loc": ["body", "grant_type"],
-                    "msg": "String should match pattern '^password$'",
-                    "input": grant_type,
-                    "ctx": {"pattern": "^password$"},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "grant_type"],
-                    "msg": 'string does not match regex "^password$"',
-                    "type": "value_error.str.regex",
-                    "ctx": {"pattern": "^password$"},
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "string_pattern_mismatch",
+                "loc": ["body", "grant_type"],
+                "msg": "String should match pattern '^password$'",
+                "input": grant_type,
+                "ctx": {"pattern": "^password$"},
+            }
+        ]
+    }
 
 
 def test_strict_login_correct_correct_grant_type():
@@ -268,26 +217,14 @@ def test_openapi_schema():
                         "username": {"title": "Username", "type": "string"},
                         "password": {"title": "Password", "type": "string"},
                         "scope": {"title": "Scope", "type": "string", "default": ""},
-                        "client_id": IsDict(
-                            {
-                                "title": "Client Id",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Client Id", "type": "string"}
-                        ),
-                        "client_secret": IsDict(
-                            {
-                                "title": "Client Secret",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Client Secret", "type": "string"}
-                        ),
+                        "client_id": {
+                            "title": "Client Id",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
+                        },
+                        "client_secret": {
+                            "title": "Client Secret",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
+                        },
                     },
                 },
                 "ValidationError": {
index ed7f4efe8a36078a8553cec2c286e2ecfedb14b4..cc7e5f5c6aa58fc9ac2b645df2848634ba62ea8d 100644 (file)
@@ -1,6 +1,5 @@
 from typing import Optional
 
-from dirty_equals import IsDict
 from fastapi import APIRouter, FastAPI
 from fastapi.testclient import TestClient
 from pydantic import BaseModel, HttpUrl
@@ -99,30 +98,18 @@ def test_openapi_schema():
                         "parameters": [
                             {
                                 "required": False,
-                                "schema": IsDict(
-                                    {
-                                        "title": "Callback Url",
-                                        "anyOf": [
-                                            {
-                                                "type": "string",
-                                                "format": "uri",
-                                                "minLength": 1,
-                                                "maxLength": 2083,
-                                            },
-                                            {"type": "null"},
-                                        ],
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {
-                                        "title": "Callback Url",
-                                        "maxLength": 2083,
-                                        "minLength": 1,
-                                        "type": "string",
-                                        "format": "uri",
-                                    }
-                                ),
+                                "schema": {
+                                    "title": "Callback Url",
+                                    "anyOf": [
+                                        {
+                                            "type": "string",
+                                            "format": "uri",
+                                            "minLength": 1,
+                                            "maxLength": 2083,
+                                        },
+                                        {"type": "null"},
+                                    ],
+                                },
                                 "name": "callback_url",
                                 "in": "query",
                             }
@@ -262,16 +249,10 @@ def test_openapi_schema():
                         "type": "object",
                         "properties": {
                             "id": {"title": "Id", "type": "string"},
-                            "title": IsDict(
-                                {
-                                    "title": "Title",
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Title", "type": "string"}
-                            ),
+                            "title": {
+                                "title": "Title",
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                            },
                             "customer": {"title": "Customer", "type": "string"},
                             "total": {"title": "Total", "type": "number"},
                         },
index fbc69a61451b6f035dbda508d11b6ca0512e7b4a..d3c89045b4c09e25982f139559ee8853ff13f062 100644 (file)
@@ -1,4 +1,3 @@
-from dirty_equals import IsDict
 from fastapi import FastAPI, Form
 from fastapi.testclient import TestClient
 from pydantic import BaseModel
@@ -125,31 +124,16 @@ def test_openapi_schema():
                     "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": IsDict(
-                                    {
-                                        "title": "Square",
-                                        "maxItems": 2,
-                                        "minItems": 2,
-                                        "type": "array",
-                                        "prefixItems": [
-                                            {"$ref": "#/components/schemas/Coordinate"},
-                                            {"$ref": "#/components/schemas/Coordinate"},
-                                        ],
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {
-                                        "title": "Square",
-                                        "maxItems": 2,
-                                        "minItems": 2,
-                                        "type": "array",
-                                        "items": [
-                                            {"$ref": "#/components/schemas/Coordinate"},
-                                            {"$ref": "#/components/schemas/Coordinate"},
-                                        ],
-                                    }
-                                )
+                                "schema": {
+                                    "title": "Square",
+                                    "maxItems": 2,
+                                    "minItems": 2,
+                                    "type": "array",
+                                    "prefixItems": [
+                                        {"$ref": "#/components/schemas/Coordinate"},
+                                        {"$ref": "#/components/schemas/Coordinate"},
+                                    ],
+                                }
                             }
                         },
                         "required": True,
@@ -212,28 +196,16 @@ def test_openapi_schema():
                     "required": ["values"],
                     "type": "object",
                     "properties": {
-                        "values": IsDict(
-                            {
-                                "title": "Values",
-                                "maxItems": 2,
-                                "minItems": 2,
-                                "type": "array",
-                                "prefixItems": [
-                                    {"type": "integer"},
-                                    {"type": "integer"},
-                                ],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {
-                                "title": "Values",
-                                "maxItems": 2,
-                                "minItems": 2,
-                                "type": "array",
-                                "items": [{"type": "integer"}, {"type": "integer"}],
-                            }
-                        )
+                        "values": {
+                            "title": "Values",
+                            "maxItems": 2,
+                            "minItems": 2,
+                            "type": "array",
+                            "prefixItems": [
+                                {"type": "integer"},
+                                {"type": "integer"},
+                            ],
+                        }
                     },
                 },
                 "Coordinate": {
@@ -264,26 +236,15 @@ def test_openapi_schema():
                         "items": {
                             "title": "Items",
                             "type": "array",
-                            "items": IsDict(
-                                {
-                                    "maxItems": 2,
-                                    "minItems": 2,
-                                    "type": "array",
-                                    "prefixItems": [
-                                        {"type": "string"},
-                                        {"type": "string"},
-                                    ],
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {
-                                    "maxItems": 2,
-                                    "minItems": 2,
-                                    "type": "array",
-                                    "items": [{"type": "string"}, {"type": "string"}],
-                                }
-                            ),
+                            "items": {
+                                "maxItems": 2,
+                                "minItems": 2,
+                                "type": "array",
+                                "prefixItems": [
+                                    {"type": "string"},
+                                    {"type": "string"},
+                                ],
+                            },
                         }
                     },
                 },
index bbcad8f294785338343ca92fca92fbefa76b1109..8208605956273a5b2ff625903607398d0317392d 100644 (file)
@@ -3,7 +3,6 @@ import os
 import shutil
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from tests.utils import needs_py310
@@ -80,16 +79,10 @@ def test_openapi_schema(client: TestClient):
                         },
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "boolean"}, {"type": "null"}],
-                                    "title": "Img",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Img", "type": "boolean"}
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "boolean"}, {"type": "null"}],
+                                "title": "Img",
+                            },
                             "name": "img",
                             "in": "query",
                         },
index cbd4fff7d6be085322d18b64a75c826c6e8423ac..c6abf5e4660c929af1d35fd368e5421b8dd2abf5 100644 (file)
@@ -3,7 +3,6 @@ import os
 import shutil
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from tests.utils import needs_py310
@@ -83,16 +82,10 @@ def test_openapi_schema(client: TestClient):
                         },
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "boolean"}, {"type": "null"}],
-                                    "title": "Img",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Img", "type": "boolean"}
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "boolean"}, {"type": "null"}],
+                                "title": "Img",
+                            },
                             "name": "img",
                             "in": "query",
                         },
index 2d1d1b03c81f89f05ff3f10bb56b962c3f78133d..a164bb80b556b30984e45de4ab3d81f7f3c44687 100644 (file)
@@ -1,5 +1,5 @@
-from dirty_equals import IsOneOf
 from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
 
 from docs_src.behind_a_proxy.tutorial003_py39 import app
 
@@ -15,40 +15,34 @@ def test_main():
 def test_openapi_schema():
     response = client.get("/openapi.json")
     assert response.status_code == 200
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "servers": [
-            {"url": "/api/v1"},
-            {
-                "url": IsOneOf(
-                    "https://stag.example.com/",
-                    # TODO: remove when deprecating Pydantic v1
-                    "https://stag.example.com",
-                ),
-                "description": "Staging environment",
-            },
-            {
-                "url": IsOneOf(
-                    "https://prod.example.com/",
-                    # TODO: remove when deprecating Pydantic v1
-                    "https://prod.example.com",
-                ),
-                "description": "Production environment",
-            },
-        ],
-        "paths": {
-            "/app": {
-                "get": {
-                    "summary": "Read Main",
-                    "operationId": "read_main_app_get",
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        }
-                    },
+    assert response.json() == snapshot(
+        {
+            "openapi": "3.1.0",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "servers": [
+                {"url": "/api/v1"},
+                {
+                    "url": "https://stag.example.com",
+                    "description": "Staging environment",
+                },
+                {
+                    "url": "https://prod.example.com",
+                    "description": "Production environment",
+                },
+            ],
+            "paths": {
+                "/app": {
+                    "get": {
+                        "summary": "Read Main",
+                        "operationId": "read_main_app_get",
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {"application/json": {"schema": {}}},
+                            }
+                        },
+                    }
                 }
-            }
-        },
-    }
+            },
+        }
+    )
index e8a03e81124a08919f95f344da473c035ac6b3d3..01bba9feddaeebff2e9759d9286fcfae31fe7ab8 100644 (file)
@@ -1,5 +1,5 @@
-from dirty_equals import IsOneOf
 from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
 
 from docs_src.behind_a_proxy.tutorial004_py39 import app
 
@@ -15,39 +15,33 @@ def test_main():
 def test_openapi_schema():
     response = client.get("/openapi.json")
     assert response.status_code == 200
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "servers": [
-            {
-                "url": IsOneOf(
-                    "https://stag.example.com/",
-                    # TODO: remove when deprecating Pydantic v1
-                    "https://stag.example.com",
-                ),
-                "description": "Staging environment",
-            },
-            {
-                "url": IsOneOf(
-                    "https://prod.example.com/",
-                    # TODO: remove when deprecating Pydantic v1
-                    "https://prod.example.com",
-                ),
-                "description": "Production environment",
-            },
-        ],
-        "paths": {
-            "/app": {
-                "get": {
-                    "summary": "Read Main",
-                    "operationId": "read_main_app_get",
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        }
-                    },
+    assert response.json() == snapshot(
+        {
+            "openapi": "3.1.0",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "servers": [
+                {
+                    "url": "https://stag.example.com",
+                    "description": "Staging environment",
+                },
+                {
+                    "url": "https://prod.example.com",
+                    "description": "Production environment",
+                },
+            ],
+            "paths": {
+                "/app": {
+                    "get": {
+                        "summary": "Read Main",
+                        "operationId": "read_main_app_get",
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {"application/json": {"schema": {}}},
+                            }
+                        },
+                    }
                 }
-            }
-        },
-    }
+            },
+        }
+    )
index 7493a9e66132b7b295de92171604cae1a9b5f7c1..f5e243b95aed355401b66935171be1358bb04708 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 
@@ -28,29 +27,16 @@ def test_users_token_jessica(client: TestClient):
 def test_users_with_no_token(client: TestClient):
     response = client.get("/users")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "token"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "token"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_users_foo_token_jessica(client: TestClient):
@@ -62,29 +48,16 @@ def test_users_foo_token_jessica(client: TestClient):
 def test_users_foo_with_no_token(client: TestClient):
     response = client.get("/users/foo")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "token"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "token"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_users_me_token_jessica(client: TestClient):
@@ -96,29 +69,16 @@ def test_users_me_token_jessica(client: TestClient):
 def test_users_me_with_no_token(client: TestClient):
     response = client.get("/users/me")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "token"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "token"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_users_token_monica_with_no_jessica(client: TestClient):
@@ -141,29 +101,16 @@ def test_items_token_jessica(client: TestClient):
 def test_items_with_no_token_jessica(client: TestClient):
     response = client.get("/items", headers={"X-Token": "fake-super-secret-token"})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "token"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "token"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_items_plumbus_token_jessica(client: TestClient):
@@ -187,29 +134,16 @@ def test_items_plumbus_with_no_token(client: TestClient):
         "/items/plumbus", headers={"X-Token": "fake-super-secret-token"}
     )
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "token"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "token"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_items_with_invalid_token(client: TestClient):
@@ -227,57 +161,31 @@ def test_items_bar_with_invalid_token(client: TestClient):
 def test_items_with_missing_x_token_header(client: TestClient):
     response = client.get("/items?token=jessica")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-token"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["header", "x-token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["header", "x-token"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_items_plumbus_with_missing_x_token_header(client: TestClient):
     response = client.get("/items/plumbus?token=jessica")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-token"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["header", "x-token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["header", "x-token"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_root_token_jessica(client: TestClient):
@@ -289,68 +197,37 @@ def test_root_token_jessica(client: TestClient):
 def test_root_with_no_token(client: TestClient):
     response = client.get("/")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "token"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "token"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_put_no_header(client: TestClient):
     response = client.put("/items/foo")
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "token"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-token"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["header", "x-token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "token"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["header", "x-token"],
+                "msg": "Field required",
+                "input": None,
+            },
+        ]
+    }
 
 
 def test_put_invalid_header(client: TestClient):
index 6aa9f2593e574495de1902f45c72472b87bc185a..5a7cae1603a1185fd686fb5219ca3f0462a03012 100644 (file)
@@ -2,7 +2,6 @@ import importlib
 from unittest.mock import patch
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
@@ -74,124 +73,67 @@ def test_post_with_str_float_description_tax(client: TestClient):
 def test_post_with_only_name(client: TestClient):
     response = client.post("/items/", json={"name": "Foo"})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "price"],
-                    "msg": "Field required",
-                    "input": {"name": "Foo"},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "price"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "price"],
+                "msg": "Field required",
+                "input": {"name": "Foo"},
+            }
+        ]
+    }
 
 
 def test_post_with_only_name_price(client: TestClient):
     response = client.post("/items/", json={"name": "Foo", "price": "twenty"})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "float_parsing",
-                    "loc": ["body", "price"],
-                    "msg": "Input should be a valid number, unable to parse string as a number",
-                    "input": "twenty",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "price"],
-                    "msg": "value is not a valid float",
-                    "type": "type_error.float",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "float_parsing",
+                "loc": ["body", "price"],
+                "msg": "Input should be a valid number, unable to parse string as a number",
+                "input": "twenty",
+            }
+        ]
+    }
 
 
 def test_post_with_no_data(client: TestClient):
     response = client.post("/items/", json={})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "name"],
-                    "msg": "Field required",
-                    "input": {},
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "price"],
-                    "msg": "Field required",
-                    "input": {},
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "name"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "price"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "name"],
+                "msg": "Field required",
+                "input": {},
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "price"],
+                "msg": "Field required",
+                "input": {},
+            },
+        ]
+    }
 
 
 def test_post_with_none(client: TestClient):
     response = client.post("/items/", json=None)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_post_broken_body(client: TestClient):
@@ -201,67 +143,32 @@ def test_post_broken_body(client: TestClient):
         content="{some broken json}",
     )
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "json_invalid",
-                    "loc": ["body", 1],
-                    "msg": "JSON decode error",
-                    "input": {},
-                    "ctx": {
-                        "error": "Expecting property name enclosed in double quotes"
-                    },
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", 1],
-                    "msg": "Expecting property name enclosed in double quotes: line 1 column 2 (char 1)",
-                    "type": "value_error.jsondecode",
-                    "ctx": {
-                        "msg": "Expecting property name enclosed in double quotes",
-                        "doc": "{some broken json}",
-                        "pos": 1,
-                        "lineno": 1,
-                        "colno": 2,
-                    },
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "json_invalid",
+                "loc": ["body", 1],
+                "msg": "JSON decode error",
+                "input": {},
+                "ctx": {"error": "Expecting property name enclosed in double quotes"},
+            }
+        ]
+    }
 
 
 def test_post_form_for_json(client: TestClient):
     response = client.post("/items/", data={"name": "Foo", "price": 50.5})
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "model_attributes_type",
-                    "loc": ["body"],
-                    "msg": "Input should be a valid dictionary or object to extract fields from",
-                    "input": "name=Foo&price=50.5",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body"],
-                    "msg": "value is not a valid dict",
-                    "type": "type_error.dict",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "model_attributes_type",
+                "loc": ["body"],
+                "msg": "Input should be a valid dictionary or object to extract fields from",
+                "input": "name=Foo&price=50.5",
+            }
+        ]
+    }
 
 
 def test_explicit_content_type(client: TestClient):
@@ -302,84 +209,46 @@ def test_wrong_headers(client: TestClient):
         "/items/", content=data, headers={"Content-Type": "text/plain"}
     )
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "model_attributes_type",
-                    "loc": ["body"],
-                    "msg": "Input should be a valid dictionary or object to extract fields from",
-                    "input": '{"name": "Foo", "price": 50.5}',
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body"],
-                    "msg": "value is not a valid dict",
-                    "type": "type_error.dict",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "model_attributes_type",
+                "loc": ["body"],
+                "msg": "Input should be a valid dictionary or object to extract fields from",
+                "input": '{"name": "Foo", "price": 50.5}',
+            }
+        ]
+    }
 
     response = client.post(
         "/items/", content=data, headers={"Content-Type": "application/geo+json-seq"}
     )
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "model_attributes_type",
-                    "loc": ["body"],
-                    "msg": "Input should be a valid dictionary or object to extract fields from",
-                    "input": '{"name": "Foo", "price": 50.5}',
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body"],
-                    "msg": "value is not a valid dict",
-                    "type": "type_error.dict",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "model_attributes_type",
+                "loc": ["body"],
+                "msg": "Input should be a valid dictionary or object to extract fields from",
+                "input": '{"name": "Foo", "price": 50.5}',
+            }
+        ]
+    }
+
     response = client.post(
         "/items/", content=data, headers={"Content-Type": "application/not-really-json"}
     )
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "model_attributes_type",
-                    "loc": ["body"],
-                    "msg": "Input should be a valid dictionary or object to extract fields from",
-                    "input": '{"name": "Foo", "price": 50.5}',
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body"],
-                    "msg": "value is not a valid dict",
-                    "type": "type_error.dict",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "model_attributes_type",
+                "loc": ["body"],
+                "msg": "Input should be a valid dictionary or object to extract fields from",
+                "input": '{"name": "Foo", "price": 50.5}',
+            }
+        ]
+    }
 
 
 def test_other_exceptions(client: TestClient):
@@ -435,26 +304,14 @@ def test_openapi_schema(client: TestClient):
                     "properties": {
                         "name": {"title": "Name", "type": "string"},
                         "price": {"title": "Price", "type": "number"},
-                        "description": IsDict(
-                            {
-                                "title": "Description",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Description", "type": "string"}
-                        ),
-                        "tax": IsDict(
-                            {
-                                "title": "Tax",
-                                "anyOf": [{"type": "number"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Tax", "type": "number"}
-                        ),
+                        "description": {
+                            "title": "Description",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
+                        },
+                        "tax": {
+                            "title": "Tax",
+                            "anyOf": [{"type": "number"}, {"type": "null"}],
+                        },
                     },
                 },
                 "ValidationError": {
index d54ec7191afa54242b64a51780c203da8a98e359..0ecadbb660d0bc757b941fa8974ae13894c1cc98 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
@@ -59,31 +58,17 @@ def test_items_6(client: TestClient):
 def test_invalid_price(client: TestClient):
     response = client.put("/items/5", json={"item": {"name": "Foo", "price": -3.0}})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "greater_than",
-                    "loc": ["body", "item", "price"],
-                    "msg": "Input should be greater than 0",
-                    "input": -3.0,
-                    "ctx": {"gt": 0.0},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "ctx": {"limit_value": 0},
-                    "loc": ["body", "item", "price"],
-                    "msg": "ensure this value is greater than 0",
-                    "type": "value_error.number.not_gt",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "greater_than",
+                "loc": ["body", "item", "price"],
+                "msg": "Input should be greater than 0",
+                "input": -3.0,
+                "ctx": {"gt": 0.0},
+            }
+        ]
+    }
 
 
 def test_openapi_schema(client: TestClient):
@@ -142,39 +127,23 @@ def test_openapi_schema(client: TestClient):
                     "type": "object",
                     "properties": {
                         "name": {"title": "Name", "type": "string"},
-                        "description": IsDict(
-                            {
-                                "title": "The description of the item",
-                                "anyOf": [
-                                    {"maxLength": 300, "type": "string"},
-                                    {"type": "null"},
-                                ],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {
-                                "title": "The description of the item",
-                                "maxLength": 300,
-                                "type": "string",
-                            }
-                        ),
+                        "description": {
+                            "title": "The description of the item",
+                            "anyOf": [
+                                {"maxLength": 300, "type": "string"},
+                                {"type": "null"},
+                            ],
+                        },
                         "price": {
                             "title": "Price",
                             "exclusiveMinimum": 0.0,
                             "type": "number",
                             "description": "The price must be greater than zero",
                         },
-                        "tax": IsDict(
-                            {
-                                "title": "Tax",
-                                "anyOf": [{"type": "number"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Tax", "type": "number"}
-                        ),
+                        "tax": {
+                            "title": "Tax",
+                            "anyOf": [{"type": "number"}, {"type": "null"}],
+                        },
                     },
                 },
                 "Body_update_item_items__item_id__put": {
index 2035cf9448d4865f224bc5d2a04dc0c6d34dec02..63c9c16d62d81c16b2cbb2959ef923d3eed8f4ba 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
@@ -53,29 +52,16 @@ def test_post_no_body(client: TestClient):
 def test_post_id_foo(client: TestClient):
     response = client.put("/items/foo", json=None)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "foo",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "foo",
+            }
+        ]
+    }
 
 
 def test_openapi_schema(client: TestClient):
@@ -119,16 +105,10 @@ def test_openapi_schema(client: TestClient):
                         },
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Q",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Q", "type": "string"}
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "Q",
+                            },
                             "name": "q",
                             "in": "query",
                         },
@@ -136,19 +116,13 @@ def test_openapi_schema(client: TestClient):
                     "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": IsDict(
-                                    {
-                                        "anyOf": [
-                                            {"$ref": "#/components/schemas/Item"},
-                                            {"type": "null"},
-                                        ],
-                                        "title": "Item",
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {"$ref": "#/components/schemas/Item"}
-                                )
+                                "schema": {
+                                    "anyOf": [
+                                        {"$ref": "#/components/schemas/Item"},
+                                        {"type": "null"},
+                                    ],
+                                    "title": "Item",
+                                }
                             }
                         }
                     },
@@ -163,27 +137,15 @@ def test_openapi_schema(client: TestClient):
                     "type": "object",
                     "properties": {
                         "name": {"title": "Name", "type": "string"},
-                        "description": IsDict(
-                            {
-                                "title": "Description",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Description", "type": "string"}
-                        ),
+                        "description": {
+                            "title": "Description",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
+                        },
                         "price": {"title": "Price", "type": "number"},
-                        "tax": IsDict(
-                            {
-                                "title": "Tax",
-                                "anyOf": [{"type": "number"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Tax", "type": "number"}
-                        ),
+                        "tax": {
+                            "title": "Tax",
+                            "anyOf": [{"type": "number"}, {"type": "null"}],
+                        },
                     },
                 },
                 "ValidationError": {
index d3e6401af229413152651b21685e012142a0da47..76b7ff7099bfd953befe1036d250f16be16e2170 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
@@ -49,101 +48,55 @@ def test_post_body_valid(client: TestClient):
 def test_post_body_no_data(client: TestClient):
     response = client.put("/items/5", json=None)
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "item"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "user"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "importance"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "item"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "user"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "importance"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "item"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "user"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "importance"],
+                "msg": "Field required",
+                "input": None,
+            },
+        ]
+    }
 
 
 def test_post_body_empty_list(client: TestClient):
     response = client.put("/items/5", json=[])
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "item"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "user"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "importance"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "item"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "user"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "importance"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "item"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "user"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "importance"],
+                "msg": "Field required",
+                "input": None,
+            },
+        ]
+    }
 
 
 def test_openapi_schema(client: TestClient):
@@ -202,27 +155,15 @@ def test_openapi_schema(client: TestClient):
                     "type": "object",
                     "properties": {
                         "name": {"title": "Name", "type": "string"},
-                        "description": IsDict(
-                            {
-                                "title": "Description",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Description", "type": "string"}
-                        ),
+                        "description": {
+                            "title": "Description",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
+                        },
                         "price": {"title": "Price", "type": "number"},
-                        "tax": IsDict(
-                            {
-                                "title": "Tax",
-                                "anyOf": [{"type": "number"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Tax", "type": "number"}
-                        ),
+                        "tax": {
+                            "title": "Tax",
+                            "anyOf": [{"type": "number"}, {"type": "null"}],
+                        },
                     },
                 },
                 "User": {
@@ -231,16 +172,10 @@ def test_openapi_schema(client: TestClient):
                     "type": "object",
                     "properties": {
                         "username": {"title": "Username", "type": "string"},
-                        "full_name": IsDict(
-                            {
-                                "title": "Full Name",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Full Name", "type": "string"}
-                        ),
+                        "full_name": {
+                            "title": "Full Name",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
+                        },
                     },
                 },
                 "Body_update_item_items__item_id__put": {
index db9f04546e3a5866dd085d6d0631b30634d78230..f2e56d40fb4246237a276f2074ba943ed9b0484c 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 
@@ -29,29 +28,16 @@ def test_post_invalid_body(client: TestClient):
     data = {"foo": 2.2, "3": 3.3}
     response = client.post("/index-weights/", json=data)
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["body", "foo", "[key]"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "foo",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "__key__"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["body", "foo", "[key]"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "foo",
+            }
+        ]
+    }
 
 
 def test_openapi_schema(client: TestClient):
index 265dee944e8a6fba0d65a34083534269f8c46a00..ac8e7bdae11586b903c4a99b8bc7e1f9afbb32b9 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 from inline_snapshot import snapshot
 
@@ -54,30 +53,16 @@ def test_cookie_param_model_invalid(client: TestClient):
     response = client.get("/items/")
     assert response.status_code == 422
     assert response.json() == snapshot(
-        IsDict(
-            {
-                "detail": [
-                    {
-                        "type": "missing",
-                        "loc": ["cookie", "session_id"],
-                        "msg": "Field required",
-                        "input": {},
-                    }
-                ]
-            }
-        )
-        | IsDict(
-            # TODO: remove when deprecating Pydantic v1
-            {
-                "detail": [
-                    {
-                        "type": "value_error.missing",
-                        "loc": ["cookie", "session_id"],
-                        "msg": "field required",
-                    }
-                ]
-            }
-        )
+        {
+            "detail": [
+                {
+                    "type": "missing",
+                    "loc": ["cookie", "session_id"],
+                    "msg": "Field required",
+                    "input": {},
+                }
+            ]
+        }
     )
 
 
@@ -115,37 +100,19 @@ def test_openapi_schema(client: TestClient):
                                 "name": "fatebook_tracker",
                                 "in": "cookie",
                                 "required": False,
-                                "schema": IsDict(
-                                    {
-                                        "anyOf": [{"type": "string"}, {"type": "null"}],
-                                        "title": "Fatebook Tracker",
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {
-                                        "type": "string",
-                                        "title": "Fatebook Tracker",
-                                    }
-                                ),
+                                "schema": {
+                                    "anyOf": [{"type": "string"}, {"type": "null"}],
+                                    "title": "Fatebook Tracker",
+                                },
                             },
                             {
                                 "name": "googall_tracker",
                                 "in": "cookie",
                                 "required": False,
-                                "schema": IsDict(
-                                    {
-                                        "anyOf": [{"type": "string"}, {"type": "null"}],
-                                        "title": "Googall Tracker",
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {
-                                        "type": "string",
-                                        "title": "Googall Tracker",
-                                    }
-                                ),
+                                "schema": {
+                                    "anyOf": [{"type": "string"}, {"type": "null"}],
+                                    "title": "Googall Tracker",
+                                },
                             },
                         ],
                         "responses": {
index 0fbf141e050d11bc70ce12e68512a06273ad2f3a..d7c3d15f1b8e39898ba955f2932d357a780fb7cb 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 from inline_snapshot import snapshot
 
@@ -72,30 +71,16 @@ def test_cookie_param_model_extra(client: TestClient):
         response = c.get("/items/")
     assert response.status_code == 422
     assert response.json() == snapshot(
-        IsDict(
-            {
-                "detail": [
-                    {
-                        "type": "extra_forbidden",
-                        "loc": ["cookie", "extra"],
-                        "msg": "Extra inputs are not permitted",
-                        "input": "track-me-here-too",
-                    }
-                ]
-            }
-        )
-        | IsDict(
-            # TODO: remove when deprecating Pydantic v1
-            {
-                "detail": [
-                    {
-                        "type": "value_error.extra",
-                        "loc": ["cookie", "extra"],
-                        "msg": "extra fields not permitted",
-                    }
-                ]
-            }
-        )
+        {
+            "detail": [
+                {
+                    "type": "extra_forbidden",
+                    "loc": ["cookie", "extra"],
+                    "msg": "Extra inputs are not permitted",
+                    "input": "track-me-here-too",
+                }
+            ]
+        }
     )
 
 
@@ -134,19 +119,10 @@ def test_openapi_schema(client: TestClient):
                                 "name": "googall_tracker",
                                 "in": "cookie",
                                 "required": False,
-                                "schema": IsDict(
-                                    {
-                                        "anyOf": [{"type": "string"}, {"type": "null"}],
-                                        "title": "Googall Tracker",
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {
-                                        "type": "string",
-                                        "title": "Googall Tracker",
-                                    }
-                                ),
+                                "schema": {
+                                    "anyOf": [{"type": "string"}, {"type": "null"}],
+                                    "title": "Googall Tracker",
+                                },
                             },
                         ],
                         "responses": {
index a65249d657c144795d5b94002f549a33d11744c4..9b47cbc67a4e7ff82c2daac6296b6fbdcdce316c 100644 (file)
@@ -2,7 +2,6 @@ import importlib
 from types import ModuleType
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
@@ -75,16 +74,10 @@ def test_openapi_schema(mod: ModuleType):
                     "parameters": [
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Ads Id",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Ads Id", "type": "string"}
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "Ads Id",
+                            },
                             "name": "ads_id",
                             "in": "cookie",
                         }
index 643011637ea0f347666994fcef38bbc29dbf3683..a9c7ae638be50827f478fb960da59b4ebc515acb 100644 (file)
@@ -1,7 +1,7 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict, IsOneOf
+from dirty_equals import IsOneOf
 from fastapi.testclient import TestClient
 
 from tests.utils import needs_py310
@@ -30,34 +30,17 @@ def test_endpoint_works(client: TestClient):
 
 def test_exception_handler_body_access(client: TestClient):
     response = client.post("/", json={"numbers": [1, 2, 3]})
-    assert response.json() == IsDict(
-        {
-            "detail": {
-                "errors": [
-                    {
-                        "type": "list_type",
-                        "loc": ["body"],
-                        "msg": "Input should be a valid list",
-                        "input": {"numbers": [1, 2, 3]},
-                    }
-                ],
-                # httpx 0.28.0 switches to compact JSON https://github.com/encode/httpx/issues/3363
-                "body": IsOneOf('{"numbers": [1, 2, 3]}', '{"numbers":[1,2,3]}'),
-            }
+    assert response.json() == {
+        "detail": {
+            "errors": [
+                {
+                    "type": "list_type",
+                    "loc": ["body"],
+                    "msg": "Input should be a valid list",
+                    "input": {"numbers": [1, 2, 3]},
+                }
+            ],
+            # httpx 0.28.0 switches to compact JSON https://github.com/encode/httpx/issues/3363
+            "body": IsOneOf('{"numbers": [1, 2, 3]}', '{"numbers":[1,2,3]}'),
         }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": {
-                # httpx 0.28.0 switches to compact JSON https://github.com/encode/httpx/issues/3363
-                "body": IsOneOf('{"numbers": [1, 2, 3]}', '{"numbers":[1,2,3]}'),
-                "errors": [
-                    {
-                        "loc": ["body"],
-                        "msg": "value is not a valid list",
-                        "type": "type_error.list",
-                    }
-                ],
-            }
-        }
-    )
+    }
index bc407234a1a839b9eb8d977b8483f6e45ac588d3..4683062f59b8250c46f8b070e240d41af48be14a 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from tests.utils import needs_py310
@@ -36,29 +35,16 @@ def test_post_item(client: TestClient):
 def test_post_invalid_item(client: TestClient):
     response = client.post("/items/", json={"name": "Foo", "price": "invalid price"})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "float_parsing",
-                    "loc": ["body", "price"],
-                    "msg": "Input should be a valid number, unable to parse string as a number",
-                    "input": "invalid price",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "price"],
-                    "msg": "value is not a valid float",
-                    "type": "type_error.float",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "float_parsing",
+                "loc": ["body", "price"],
+                "msg": "Input should be a valid number, unable to parse string as a number",
+                "input": "invalid price",
+            }
+        ]
+    }
 
 
 def test_openapi_schema(client: TestClient):
@@ -119,26 +105,14 @@ def test_openapi_schema(client: TestClient):
                     "properties": {
                         "name": {"title": "Name", "type": "string"},
                         "price": {"title": "Price", "type": "number"},
-                        "description": IsDict(
-                            {
-                                "title": "Description",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Description", "type": "string"}
-                        ),
-                        "tax": IsDict(
-                            {
-                                "title": "Tax",
-                                "anyOf": [{"type": "number"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Tax", "type": "number"}
-                        ),
+                        "description": {
+                            "title": "Description",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
+                        },
+                        "tax": {
+                            "title": "Tax",
+                            "anyOf": [{"type": "number"}, {"type": "null"}],
+                        },
                     },
                 },
                 "ValidationError": {
index 995d926752abdd472cdcb59a0609a8821ad97e15..210d743bb861fbe35ce416e4829433b5532d90e6 100644 (file)
@@ -1,8 +1,8 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict, IsOneOf
 from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
 
 from tests.utils import needs_py310
 
@@ -37,77 +37,53 @@ def test_get_item(client: TestClient):
 def test_openapi_schema(client: TestClient):
     response = client.get("/openapi.json")
     assert response.status_code == 200
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/next": {
-                "get": {
-                    "summary": "Read Next Item",
-                    "operationId": "read_next_item_items_next_get",
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {
-                                "application/json": {
-                                    "schema": {"$ref": "#/components/schemas/Item"}
-                                }
-                            },
-                        }
-                    },
-                }
-            }
-        },
-        "components": {
-            "schemas": {
-                "Item": {
-                    "title": "Item",
-                    "required": IsOneOf(
-                        ["name", "price", "tags", "description", "tax"],
-                        # TODO: remove when deprecating Pydantic v1
-                        ["name", "price"],
-                    ),
-                    "type": "object",
-                    "properties": {
-                        "name": {"title": "Name", "type": "string"},
-                        "price": {"title": "Price", "type": "number"},
-                        "tags": IsDict(
-                            {
-                                "title": "Tags",
-                                "type": "array",
-                                "items": {"type": "string"},
+    assert response.json() == snapshot(
+        {
+            "openapi": "3.1.0",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "paths": {
+                "/items/next": {
+                    "get": {
+                        "summary": "Read Next Item",
+                        "operationId": "read_next_item_items_next_get",
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {"$ref": "#/components/schemas/Item"}
+                                    }
+                                },
                             }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {
+                        },
+                    }
+                }
+            },
+            "components": {
+                "schemas": {
+                    "Item": {
+                        "title": "Item",
+                        "required": ["name", "price"],
+                        "type": "object",
+                        "properties": {
+                            "name": {"title": "Name", "type": "string"},
+                            "price": {"title": "Price", "type": "number"},
+                            "tags": {
                                 "title": "Tags",
                                 "type": "array",
                                 "items": {"type": "string"},
-                            }
-                        ),
-                        "description": IsDict(
-                            {
+                            },
+                            "description": {
                                 "title": "Description",
                                 "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Description", "type": "string"}
-                        ),
-                        "tax": IsDict(
-                            {
+                            },
+                            "tax": {
                                 "title": "Tax",
                                 "anyOf": [{"type": "number"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Tax", "type": "number"}
-                        ),
-                    },
+                            },
+                        },
+                    }
                 }
-            }
-        },
-    }
+            },
+        }
+    )
index 46f0066f9f05ae9e374c00873b4275612f6a6c02..59202df3bf65c61fae40be4465fae97e5417fb65 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 
@@ -22,40 +21,22 @@ def get_client(request: pytest.FixtureRequest):
 def test_get_no_headers(client: TestClient):
     response = client.get("/items/")
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-token"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-key"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["header", "x-token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["header", "x-key"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["header", "x-token"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["header", "x-key"],
+                "msg": "Field required",
+                "input": None,
+            },
+        ]
+    }
 
 
 def test_get_invalid_one_header(client: TestClient):
index b791ee0aa150c2666c4a6b16781309696c3f2da4..d5599ac73a002d53d8d31a95d2ee52446e43d0c0 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 
@@ -22,79 +21,43 @@ def get_client(request: pytest.FixtureRequest):
 def test_get_no_headers_items(client: TestClient):
     response = client.get("/items/")
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-token"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-key"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["header", "x-token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["header", "x-key"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["header", "x-token"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["header", "x-key"],
+                "msg": "Field required",
+                "input": None,
+            },
+        ]
+    }
 
 
 def test_get_no_headers_users(client: TestClient):
     response = client.get("/users/")
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-token"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["header", "x-key"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["header", "x-token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["header", "x-key"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["header", "x-token"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["header", "x-key"],
+                "msg": "Field required",
+                "input": None,
+            },
+        ]
+    }
 
 
 def test_get_invalid_one_header_items(client: TestClient):
index e11f73fe352f898135473c987116ea26ef5e308e..5479e2925241eb0b6d2b96a5c7abcd603e309865 100644 (file)
@@ -1,8 +1,8 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
 
 from ...utils import needs_py310
 
@@ -47,146 +47,117 @@ def test_extra_types(client: TestClient):
 def test_openapi_schema(client: TestClient):
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/{item_id}": {
-                "put": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
+    assert response.json() == snapshot(
+        {
+            "openapi": "3.1.0",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "paths": {
+                "/items/{item_id}": {
+                    "put": {
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {"application/json": {"schema": {}}},
+                            },
+                            "422": {
+                                "description": "Validation Error",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/HTTPValidationError"
+                                        }
+                                    }
+                                },
+                            },
                         },
-                        "422": {
-                            "description": "Validation Error",
+                        "summary": "Read Items",
+                        "operationId": "read_items_items__item_id__put",
+                        "parameters": [
+                            {
+                                "required": True,
+                                "schema": {
+                                    "title": "Item Id",
+                                    "type": "string",
+                                    "format": "uuid",
+                                },
+                                "name": "item_id",
+                                "in": "path",
+                            }
+                        ],
+                        "requestBody": {
+                            "required": True,
                             "content": {
                                 "application/json": {
                                     "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                        "$ref": "#/components/schemas/Body_read_items_items__item_id__put"
                                     }
                                 }
                             },
                         },
-                    },
-                    "summary": "Read Items",
-                    "operationId": "read_items_items__item_id__put",
-                    "parameters": [
-                        {
-                            "required": True,
-                            "schema": {
-                                "title": "Item Id",
+                    }
+                }
+            },
+            "components": {
+                "schemas": {
+                    "Body_read_items_items__item_id__put": {
+                        "title": "Body_read_items_items__item_id__put",
+                        "type": "object",
+                        "properties": {
+                            "start_datetime": {
+                                "title": "Start Datetime",
                                 "type": "string",
-                                "format": "uuid",
+                                "format": "date-time",
                             },
-                            "name": "item_id",
-                            "in": "path",
-                        }
-                    ],
-                    "requestBody": {
-                        "required": True,
-                        "content": {
-                            "application/json": {
-                                "schema": IsDict(
-                                    {
-                                        "allOf": [
-                                            {
-                                                "$ref": "#/components/schemas/Body_read_items_items__item_id__put"
-                                            }
-                                        ],
-                                        "title": "Body",
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {
-                                        "$ref": "#/components/schemas/Body_read_items_items__item_id__put"
-                                    }
-                                )
-                            }
-                        },
-                    },
-                }
-            }
-        },
-        "components": {
-            "schemas": {
-                "Body_read_items_items__item_id__put": {
-                    "title": "Body_read_items_items__item_id__put",
-                    "type": "object",
-                    "properties": {
-                        "start_datetime": {
-                            "title": "Start Datetime",
-                            "type": "string",
-                            "format": "date-time",
-                        },
-                        "end_datetime": {
-                            "title": "End Datetime",
-                            "type": "string",
-                            "format": "date-time",
-                        },
-                        "repeat_at": IsDict(
-                            {
+                            "end_datetime": {
+                                "title": "End Datetime",
+                                "type": "string",
+                                "format": "date-time",
+                            },
+                            "repeat_at": {
                                 "title": "Repeat At",
                                 "anyOf": [
                                     {"type": "string", "format": "time"},
                                     {"type": "null"},
                                 ],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {
-                                "title": "Repeat At",
-                                "type": "string",
-                                "format": "time",
-                            }
-                        ),
-                        "process_after": IsDict(
-                            {
+                            },
+                            "process_after": {
                                 "title": "Process After",
                                 "type": "string",
                                 "format": "duration",
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {
-                                "title": "Process After",
-                                "type": "number",
-                                "format": "time-delta",
-                            }
-                        ),
+                            },
+                        },
+                        "required": ["start_datetime", "end_datetime", "process_after"],
                     },
-                    "required": ["start_datetime", "end_datetime", "process_after"],
-                },
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                    "ValidationError": {
+                        "title": "ValidationError",
+                        "required": ["loc", "msg", "type"],
+                        "type": "object",
+                        "properties": {
+                            "loc": {
+                                "title": "Location",
+                                "type": "array",
+                                "items": {
+                                    "anyOf": [{"type": "string"}, {"type": "integer"}]
+                                },
                             },
+                            "msg": {"title": "Message", "type": "string"},
+                            "type": {"title": "Error Type", "type": "string"},
                         },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
                     },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
+                    "HTTPValidationError": {
+                        "title": "HTTPValidationError",
+                        "type": "object",
+                        "properties": {
+                            "detail": {
+                                "title": "Detail",
+                                "type": "array",
+                                "items": {
+                                    "$ref": "#/components/schemas/ValidationError"
+                                },
+                            }
+                        },
                     },
-                },
-            }
-        },
-    }
+                }
+            },
+        }
+    )
index 3aa83c0c40062ad9ba5a52aa3a2cb12455f3dd25..872af53830433236ba371a0312549212c13ad707 100644 (file)
@@ -1,8 +1,8 @@
 import importlib
 
 import pytest
-from dirty_equals import IsOneOf
 from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
 
 from ...utils import needs_py310
 
@@ -43,107 +43,115 @@ def test_get_plane(client: TestClient):
 def test_openapi_schema(client: TestClient):
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/{item_id}": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "title": "Response Read Item Items  Item Id  Get",
-                                        "anyOf": [
-                                            {"$ref": "#/components/schemas/PlaneItem"},
-                                            {"$ref": "#/components/schemas/CarItem"},
-                                        ],
+    assert response.json() == snapshot(
+        {
+            "openapi": "3.1.0",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "paths": {
+                "/items/{item_id}": {
+                    "get": {
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "title": "Response Read Item Items  Item Id  Get",
+                                            "anyOf": [
+                                                {
+                                                    "$ref": "#/components/schemas/PlaneItem"
+                                                },
+                                                {
+                                                    "$ref": "#/components/schemas/CarItem"
+                                                },
+                                            ],
+                                        }
                                     }
-                                }
+                                },
                             },
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
+                            "422": {
+                                "description": "Validation Error",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/HTTPValidationError"
+                                        }
                                     }
-                                }
+                                },
                             },
                         },
-                    },
-                    "summary": "Read Item",
-                    "operationId": "read_item_items__item_id__get",
-                    "parameters": [
-                        {
-                            "required": True,
-                            "schema": {"title": "Item Id", "type": "string"},
-                            "name": "item_id",
-                            "in": "path",
-                        }
-                    ],
+                        "summary": "Read Item",
+                        "operationId": "read_item_items__item_id__get",
+                        "parameters": [
+                            {
+                                "required": True,
+                                "schema": {"title": "Item Id", "type": "string"},
+                                "name": "item_id",
+                                "in": "path",
+                            }
+                        ],
+                    }
                 }
-            }
-        },
-        "components": {
-            "schemas": {
-                "PlaneItem": {
-                    "title": "PlaneItem",
-                    "required": IsOneOf(
-                        ["description", "type", "size"],
-                        # TODO: remove when deprecating Pydantic v1
-                        ["description", "size"],
-                    ),
-                    "type": "object",
-                    "properties": {
-                        "description": {"title": "Description", "type": "string"},
-                        "type": {"title": "Type", "type": "string", "default": "plane"},
-                        "size": {"title": "Size", "type": "integer"},
+            },
+            "components": {
+                "schemas": {
+                    "PlaneItem": {
+                        "title": "PlaneItem",
+                        "required": ["description", "size"],
+                        "type": "object",
+                        "properties": {
+                            "description": {"title": "Description", "type": "string"},
+                            "type": {
+                                "title": "Type",
+                                "type": "string",
+                                "default": "plane",
+                            },
+                            "size": {"title": "Size", "type": "integer"},
+                        },
                     },
-                },
-                "CarItem": {
-                    "title": "CarItem",
-                    "required": IsOneOf(
-                        ["description", "type"],
-                        # TODO: remove when deprecating Pydantic v1
-                        ["description"],
-                    ),
-                    "type": "object",
-                    "properties": {
-                        "description": {"title": "Description", "type": "string"},
-                        "type": {"title": "Type", "type": "string", "default": "car"},
+                    "CarItem": {
+                        "title": "CarItem",
+                        "required": ["description"],
+                        "type": "object",
+                        "properties": {
+                            "description": {"title": "Description", "type": "string"},
+                            "type": {
+                                "title": "Type",
+                                "type": "string",
+                                "default": "car",
+                            },
+                        },
                     },
-                },
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                    "ValidationError": {
+                        "title": "ValidationError",
+                        "required": ["loc", "msg", "type"],
+                        "type": "object",
+                        "properties": {
+                            "loc": {
+                                "title": "Location",
+                                "type": "array",
+                                "items": {
+                                    "anyOf": [{"type": "string"}, {"type": "integer"}]
+                                },
                             },
+                            "msg": {"title": "Message", "type": "string"},
+                            "type": {"title": "Error Type", "type": "string"},
                         },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
                     },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
+                    "HTTPValidationError": {
+                        "title": "HTTPValidationError",
+                        "type": "object",
+                        "properties": {
+                            "detail": {
+                                "title": "Detail",
+                                "type": "array",
+                                "items": {
+                                    "$ref": "#/components/schemas/ValidationError"
+                                },
+                            }
+                        },
                     },
-                },
-            }
-        },
-    }
+                }
+            },
+        }
+    )
index d713c5d8761f726bbfa6631035e88ebad7c3d8f4..7bd947f194fffc31d8d133ea772e9175db004d46 100644 (file)
@@ -1,4 +1,3 @@
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from docs_src.handling_errors.tutorial005_py39 import app
@@ -9,31 +8,17 @@ client = TestClient(app)
 def test_post_validation_error():
     response = client.post("/items/", json={"title": "towel", "size": "XL"})
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["body", "size"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "XL",
-                }
-            ],
-            "body": {"title": "towel", "size": "XL"},
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "size"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ],
-            "body": {"title": "towel", "size": "XL"},
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["body", "size"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "XL",
+            }
+        ],
+        "body": {"title": "towel", "size": "XL"},
+    }
 
 
 def test_post():
index 491e461b3db6b458157016ec348c4e01190db91b..e95e53d5ed9f3be67b6af72df86b855a45a8b64b 100644 (file)
@@ -1,4 +1,3 @@
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from docs_src.handling_errors.tutorial006_py39 import app
@@ -9,29 +8,16 @@ client = TestClient(app)
 def test_get_validation_error():
     response = client.get("/items/foo")
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "int_parsing",
-                    "loc": ["path", "item_id"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "foo",
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["path", "item_id"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "int_parsing",
+                "loc": ["path", "item_id"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "foo",
+            }
+        ]
+    }
 
 
 def test_get_http_error():
index f59d50762c0fdea9bf0377f80f39fd532ffafd2e..1fa8aee461a9e8986e752db1a017ca472007cf5e 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 from inline_snapshot import snapshot
 
@@ -63,29 +62,19 @@ def test_header_param_model_invalid(client: TestClient):
     assert response.json() == snapshot(
         {
             "detail": [
-                IsDict(
-                    {
-                        "type": "missing",
-                        "loc": ["header", "save_data"],
-                        "msg": "Field required",
-                        "input": {
-                            "x_tag": [],
-                            "host": "testserver",
-                            "accept": "*/*",
-                            "accept-encoding": "gzip, deflate",
-                            "connection": "keep-alive",
-                            "user-agent": "testclient",
-                        },
-                    }
-                )
-                | IsDict(
-                    # TODO: remove when deprecating Pydantic v1
-                    {
-                        "type": "value_error.missing",
-                        "loc": ["header", "save_data"],
-                        "msg": "field required",
-                    }
-                )
+                {
+                    "type": "missing",
+                    "loc": ["header", "save_data"],
+                    "msg": "Field required",
+                    "input": {
+                        "x_tag": [],
+                        "host": "testserver",
+                        "accept": "*/*",
+                        "accept-encoding": "gzip, deflate",
+                        "connection": "keep-alive",
+                        "user-agent": "testclient",
+                    },
+                }
             ]
         }
     )
@@ -136,37 +125,19 @@ def test_openapi_schema(client: TestClient):
                                 "name": "if-modified-since",
                                 "in": "header",
                                 "required": False,
-                                "schema": IsDict(
-                                    {
-                                        "anyOf": [{"type": "string"}, {"type": "null"}],
-                                        "title": "If Modified Since",
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {
-                                        "type": "string",
-                                        "title": "If Modified Since",
-                                    }
-                                ),
+                                "schema": {
+                                    "anyOf": [{"type": "string"}, {"type": "null"}],
+                                    "title": "If Modified Since",
+                                },
                             },
                             {
                                 "name": "traceparent",
                                 "in": "header",
                                 "required": False,
-                                "schema": IsDict(
-                                    {
-                                        "anyOf": [{"type": "string"}, {"type": "null"}],
-                                        "title": "Traceparent",
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {
-                                        "type": "string",
-                                        "title": "Traceparent",
-                                    }
-                                ),
+                                "schema": {
+                                    "anyOf": [{"type": "string"}, {"type": "null"}],
+                                    "title": "Traceparent",
+                                },
                             },
                             {
                                 "name": "x-tag",
index ed4743ebf9bcd38690131ee49d9c29d8558c57c8..079a8f5402d2af451bc30b972dfefd0b8a4dabcf 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 from inline_snapshot import snapshot
 
@@ -64,22 +63,12 @@ def test_header_param_model_invalid(client: TestClient):
     assert response.json() == snapshot(
         {
             "detail": [
-                IsDict(
-                    {
-                        "type": "missing",
-                        "loc": ["header", "save_data"],
-                        "msg": "Field required",
-                        "input": {"x_tag": [], "host": "testserver"},
-                    }
-                )
-                | IsDict(
-                    # TODO: remove when deprecating Pydantic v1
-                    {
-                        "type": "value_error.missing",
-                        "loc": ["header", "save_data"],
-                        "msg": "field required",
-                    }
-                )
+                {
+                    "type": "missing",
+                    "loc": ["header", "save_data"],
+                    "msg": "Field required",
+                    "input": {"x_tag": [], "host": "testserver"},
+                }
             ]
         }
     )
@@ -93,22 +82,12 @@ def test_header_param_model_extra(client: TestClient):
     assert response.json() == snapshot(
         {
             "detail": [
-                IsDict(
-                    {
-                        "type": "extra_forbidden",
-                        "loc": ["header", "tool"],
-                        "msg": "Extra inputs are not permitted",
-                        "input": "plumbus",
-                    }
-                )
-                | IsDict(
-                    # TODO: remove when deprecating Pydantic v1
-                    {
-                        "type": "value_error.extra",
-                        "loc": ["header", "tool"],
-                        "msg": "extra fields not permitted",
-                    }
-                )
+                {
+                    "type": "extra_forbidden",
+                    "loc": ["header", "tool"],
+                    "msg": "Extra inputs are not permitted",
+                    "input": "plumbus",
+                }
             ]
         }
     )
@@ -143,37 +122,19 @@ def test_openapi_schema(client: TestClient):
                                 "name": "if-modified-since",
                                 "in": "header",
                                 "required": False,
-                                "schema": IsDict(
-                                    {
-                                        "anyOf": [{"type": "string"}, {"type": "null"}],
-                                        "title": "If Modified Since",
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {
-                                        "type": "string",
-                                        "title": "If Modified Since",
-                                    }
-                                ),
+                                "schema": {
+                                    "anyOf": [{"type": "string"}, {"type": "null"}],
+                                    "title": "If Modified Since",
+                                },
                             },
                             {
                                 "name": "traceparent",
                                 "in": "header",
                                 "required": False,
-                                "schema": IsDict(
-                                    {
-                                        "anyOf": [{"type": "string"}, {"type": "null"}],
-                                        "title": "Traceparent",
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {
-                                        "type": "string",
-                                        "title": "Traceparent",
-                                    }
-                                ),
+                                "schema": {
+                                    "anyOf": [{"type": "string"}, {"type": "null"}],
+                                    "title": "Traceparent",
+                                },
                             },
                             {
                                 "name": "x-tag",
index 947587504ff7a2cce5ce53f50f117b9df872ab1c..4c89d80ee21ce8dc1f13d9b961bfe84228b2644a 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 from inline_snapshot import snapshot
 
@@ -60,33 +59,23 @@ def test_header_param_model_no_underscore(client: TestClient):
     assert response.json() == snapshot(
         {
             "detail": [
-                IsDict(
-                    {
-                        "type": "missing",
-                        "loc": ["header", "save_data"],
-                        "msg": "Field required",
-                        "input": {
-                            "host": "testserver",
-                            "traceparent": "123",
-                            "x_tag": [],
-                            "accept": "*/*",
-                            "accept-encoding": "gzip, deflate",
-                            "connection": "keep-alive",
-                            "user-agent": "testclient",
-                            "save-data": "true",
-                            "if-modified-since": "yesterday",
-                            "x-tag": ["one", "two"],
-                        },
-                    }
-                )
-                | IsDict(
-                    # TODO: remove when deprecating Pydantic v1
-                    {
-                        "type": "value_error.missing",
-                        "loc": ["header", "save_data"],
-                        "msg": "field required",
-                    }
-                )
+                {
+                    "type": "missing",
+                    "loc": ["header", "save_data"],
+                    "msg": "Field required",
+                    "input": {
+                        "host": "testserver",
+                        "traceparent": "123",
+                        "x_tag": [],
+                        "accept": "*/*",
+                        "accept-encoding": "gzip, deflate",
+                        "connection": "keep-alive",
+                        "user-agent": "testclient",
+                        "save-data": "true",
+                        "if-modified-since": "yesterday",
+                        "x-tag": ["one", "two"],
+                    },
+                }
             ]
         }
     )
@@ -110,29 +99,19 @@ def test_header_param_model_invalid(client: TestClient):
     assert response.json() == snapshot(
         {
             "detail": [
-                IsDict(
-                    {
-                        "type": "missing",
-                        "loc": ["header", "save_data"],
-                        "msg": "Field required",
-                        "input": {
-                            "x_tag": [],
-                            "host": "testserver",
-                            "accept": "*/*",
-                            "accept-encoding": "gzip, deflate",
-                            "connection": "keep-alive",
-                            "user-agent": "testclient",
-                        },
-                    }
-                )
-                | IsDict(
-                    # TODO: remove when deprecating Pydantic v1
-                    {
-                        "type": "value_error.missing",
-                        "loc": ["header", "save_data"],
-                        "msg": "field required",
-                    }
-                )
+                {
+                    "type": "missing",
+                    "loc": ["header", "save_data"],
+                    "msg": "Field required",
+                    "input": {
+                        "x_tag": [],
+                        "host": "testserver",
+                        "accept": "*/*",
+                        "accept-encoding": "gzip, deflate",
+                        "connection": "keep-alive",
+                        "user-agent": "testclient",
+                    },
+                }
             ]
         }
     )
@@ -183,37 +162,19 @@ def test_openapi_schema(client: TestClient):
                                 "name": "if_modified_since",
                                 "in": "header",
                                 "required": False,
-                                "schema": IsDict(
-                                    {
-                                        "anyOf": [{"type": "string"}, {"type": "null"}],
-                                        "title": "If Modified Since",
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {
-                                        "type": "string",
-                                        "title": "If Modified Since",
-                                    }
-                                ),
+                                "schema": {
+                                    "anyOf": [{"type": "string"}, {"type": "null"}],
+                                    "title": "If Modified Since",
+                                },
                             },
                             {
                                 "name": "traceparent",
                                 "in": "header",
                                 "required": False,
-                                "schema": IsDict(
-                                    {
-                                        "anyOf": [{"type": "string"}, {"type": "null"}],
-                                        "title": "Traceparent",
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {
-                                        "type": "string",
-                                        "title": "Traceparent",
-                                    }
-                                ),
+                                "schema": {
+                                    "anyOf": [{"type": "string"}, {"type": "null"}],
+                                    "title": "Traceparent",
+                                },
                             },
                             {
                                 "name": "x_tag",
index beaf917f924df547a13aee78597f191b19721fa3..88591b82258275bc605cf183e4c80d7d4324a61b 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
@@ -67,16 +66,10 @@ def test_openapi_schema(client: TestClient):
                     "parameters": [
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "User-Agent",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "User-Agent", "type": "string"}
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "User-Agent",
+                            },
                             "name": "user-agent",
                             "in": "header",
                         }
index b892ff905f8f13580c48842663f2567f88e7e320..229f96c1f8401e0a726a9a28e94cc3e6d6296527 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
@@ -78,16 +77,10 @@ def test_openapi_schema(client: TestClient):
                     "parameters": [
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Strange Header",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Strange Header", "type": "string"}
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "Strange Header",
+                            },
                             "name": "strange_header",
                             "in": "header",
                         }
index ef762441590c6b970b6a938d9304f8a4240714d9..cf067ccf9e3a57a4e56b4a489af1376cff61bd2d 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
@@ -56,23 +55,13 @@ def test_openapi_schema(client: TestClient):
                     "parameters": [
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "title": "X-Token",
-                                    "anyOf": [
-                                        {"type": "array", "items": {"type": "string"}},
-                                        {"type": "null"},
-                                    ],
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {
-                                    "title": "X-Token",
-                                    "type": "array",
-                                    "items": {"type": "string"},
-                                }
-                            ),
+                            "schema": {
+                                "title": "X-Token",
+                                "anyOf": [
+                                    {"type": "array", "items": {"type": "string"}},
+                                    {"type": "null"},
+                                ],
+                            },
                             "name": "x-token",
                             "in": "header",
                         }
index 975e07cbdd4dcb4215b06c9ed43927cdef7421d1..6fde96cb5b1ee56205fb29a743587d09d089568c 100644 (file)
@@ -2,7 +2,6 @@ import importlib
 from types import ModuleType
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from tests.utils import needs_py310
@@ -55,30 +54,18 @@ def test_openapi_schema(client: TestClient):
                     "parameters": [
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [
-                                        {
-                                            "type": "string",
-                                            "format": "uri",
-                                            "minLength": 1,
-                                            "maxLength": 2083,
-                                        },
-                                        {"type": "null"},
-                                    ],
-                                    "title": "Callback Url",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {
-                                    "title": "Callback Url",
-                                    "maxLength": 2083,
-                                    "minLength": 1,
-                                    "type": "string",
-                                    "format": "uri",
-                                }
-                            ),
+                            "schema": {
+                                "anyOf": [
+                                    {
+                                        "type": "string",
+                                        "format": "uri",
+                                        "minLength": 1,
+                                        "maxLength": 2083,
+                                    },
+                                    {"type": "null"},
+                                ],
+                                "title": "Callback Url",
+                            },
                             "name": "callback_url",
                             "in": "query",
                         }
@@ -171,16 +158,10 @@ def test_openapi_schema(client: TestClient):
                     "type": "object",
                     "properties": {
                         "id": {"title": "Id", "type": "string"},
-                        "title": IsDict(
-                            {
-                                "title": "Title",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Title", "type": "string"}
-                        ),
+                        "title": {
+                            "title": "Title",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
+                        },
                         "customer": {"title": "Customer", "type": "string"},
                         "total": {"title": "Total", "type": "number"},
                     },
index b3be70471af8cd0d6a9caab676120e90ad8a7f77..86ccce7b6d35d8c1a31a16fb5b4a7e8b62a4fbaf 100644 (file)
@@ -1,4 +1,3 @@
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from docs_src.path_params.tutorial005_py39 import app
@@ -27,31 +26,17 @@ def test_get_enums_resnet():
 def test_get_enums_invalid():
     response = client.get("/models/foo")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "enum",
-                    "loc": ["path", "model_name"],
-                    "msg": "Input should be 'alexnet', 'resnet' or 'lenet'",
-                    "input": "foo",
-                    "ctx": {"expected": "'alexnet', 'resnet' or 'lenet'"},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "ctx": {"enum_values": ["alexnet", "resnet", "lenet"]},
-                    "loc": ["path", "model_name"],
-                    "msg": "value is not a valid enumeration member; permitted: 'alexnet', 'resnet', 'lenet'",
-                    "type": "type_error.enum",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "enum",
+                "loc": ["path", "model_name"],
+                "msg": "Input should be 'alexnet', 'resnet' or 'lenet'",
+                "input": "foo",
+                "ctx": {"expected": "'alexnet', 'resnet' or 'lenet'"},
+            }
+        ]
+    }
 
 
 def test_openapi_schema():
@@ -106,22 +91,11 @@ def test_openapi_schema():
                         }
                     },
                 },
-                "ModelName": IsDict(
-                    {
-                        "title": "ModelName",
-                        "enum": ["alexnet", "resnet", "lenet"],
-                        "type": "string",
-                    }
-                )
-                | IsDict(
-                    {
-                        # TODO: remove when deprecating Pydantic v1
-                        "title": "ModelName",
-                        "enum": ["alexnet", "resnet", "lenet"],
-                        "type": "string",
-                        "description": "An enumeration.",
-                    }
-                ),
+                "ModelName": {
+                    "title": "ModelName",
+                    "enum": ["alexnet", "resnet", "lenet"],
+                    "type": "string",
+                },
                 "ValidationError": {
                     "title": "ValidationError",
                     "required": ["loc", "msg", "type"],
index 86830b9341eb2d85029c67c2220651a50309ba6b..d3ce57121d14a88e69e115d44c29b039cf721cfe 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 from inline_snapshot import snapshot
 
@@ -65,61 +64,31 @@ def test_query_param_model_invalid(client: TestClient):
     )
     assert response.status_code == 422
     assert response.json() == snapshot(
-        IsDict(
-            {
-                "detail": [
-                    {
-                        "type": "less_than_equal",
-                        "loc": ["query", "limit"],
-                        "msg": "Input should be less than or equal to 100",
-                        "input": "150",
-                        "ctx": {"le": 100},
-                    },
-                    {
-                        "type": "greater_than_equal",
-                        "loc": ["query", "offset"],
-                        "msg": "Input should be greater than or equal to 0",
-                        "input": "-1",
-                        "ctx": {"ge": 0},
-                    },
-                    {
-                        "type": "literal_error",
-                        "loc": ["query", "order_by"],
-                        "msg": "Input should be 'created_at' or 'updated_at'",
-                        "input": "invalid",
-                        "ctx": {"expected": "'created_at' or 'updated_at'"},
-                    },
-                ]
-            }
-        )
-        | IsDict(
-            # TODO: remove when deprecating Pydantic v1
-            {
-                "detail": [
-                    {
-                        "type": "value_error.number.not_le",
-                        "loc": ["query", "limit"],
-                        "msg": "ensure this value is less than or equal to 100",
-                        "ctx": {"limit_value": 100},
-                    },
-                    {
-                        "type": "value_error.number.not_ge",
-                        "loc": ["query", "offset"],
-                        "msg": "ensure this value is greater than or equal to 0",
-                        "ctx": {"limit_value": 0},
-                    },
-                    {
-                        "type": "value_error.const",
-                        "loc": ["query", "order_by"],
-                        "msg": "unexpected value; permitted: 'created_at', 'updated_at'",
-                        "ctx": {
-                            "given": "invalid",
-                            "permitted": ["created_at", "updated_at"],
-                        },
-                    },
-                ]
-            }
-        )
+        {
+            "detail": [
+                {
+                    "type": "less_than_equal",
+                    "loc": ["query", "limit"],
+                    "msg": "Input should be less than or equal to 100",
+                    "input": "150",
+                    "ctx": {"le": 100},
+                },
+                {
+                    "type": "greater_than_equal",
+                    "loc": ["query", "offset"],
+                    "msg": "Input should be greater than or equal to 0",
+                    "input": "-1",
+                    "ctx": {"ge": 0},
+                },
+                {
+                    "type": "literal_error",
+                    "loc": ["query", "order_by"],
+                    "msg": "Input should be 'created_at' or 'updated_at'",
+                    "input": "invalid",
+                    "ctx": {"expected": "'created_at' or 'updated_at'"},
+                },
+            ]
+        }
     )
 
 
index 0e9c3351a0af26761193d093f33ace043bd51c1e..96abce6ab9766636a3d12699bbb193db00da64a6 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 from inline_snapshot import snapshot
 
@@ -65,61 +64,31 @@ def test_query_param_model_invalid(client: TestClient):
     )
     assert response.status_code == 422
     assert response.json() == snapshot(
-        IsDict(
-            {
-                "detail": [
-                    {
-                        "type": "less_than_equal",
-                        "loc": ["query", "limit"],
-                        "msg": "Input should be less than or equal to 100",
-                        "input": "150",
-                        "ctx": {"le": 100},
-                    },
-                    {
-                        "type": "greater_than_equal",
-                        "loc": ["query", "offset"],
-                        "msg": "Input should be greater than or equal to 0",
-                        "input": "-1",
-                        "ctx": {"ge": 0},
-                    },
-                    {
-                        "type": "literal_error",
-                        "loc": ["query", "order_by"],
-                        "msg": "Input should be 'created_at' or 'updated_at'",
-                        "input": "invalid",
-                        "ctx": {"expected": "'created_at' or 'updated_at'"},
-                    },
-                ]
-            }
-        )
-        | IsDict(
-            # TODO: remove when deprecating Pydantic v1
-            {
-                "detail": [
-                    {
-                        "type": "value_error.number.not_le",
-                        "loc": ["query", "limit"],
-                        "msg": "ensure this value is less than or equal to 100",
-                        "ctx": {"limit_value": 100},
-                    },
-                    {
-                        "type": "value_error.number.not_ge",
-                        "loc": ["query", "offset"],
-                        "msg": "ensure this value is greater than or equal to 0",
-                        "ctx": {"limit_value": 0},
-                    },
-                    {
-                        "type": "value_error.const",
-                        "loc": ["query", "order_by"],
-                        "msg": "unexpected value; permitted: 'created_at', 'updated_at'",
-                        "ctx": {
-                            "given": "invalid",
-                            "permitted": ["created_at", "updated_at"],
-                        },
-                    },
-                ]
-            }
-        )
+        {
+            "detail": [
+                {
+                    "type": "less_than_equal",
+                    "loc": ["query", "limit"],
+                    "msg": "Input should be less than or equal to 100",
+                    "input": "150",
+                    "ctx": {"le": 100},
+                },
+                {
+                    "type": "greater_than_equal",
+                    "loc": ["query", "offset"],
+                    "msg": "Input should be greater than or equal to 0",
+                    "input": "-1",
+                    "ctx": {"ge": 0},
+                },
+                {
+                    "type": "literal_error",
+                    "loc": ["query", "order_by"],
+                    "msg": "Input should be 'created_at' or 'updated_at'",
+                    "input": "invalid",
+                    "ctx": {"expected": "'created_at' or 'updated_at'"},
+                },
+            ]
+        }
     )
 
 
@@ -138,22 +107,12 @@ def test_query_param_model_extra(client: TestClient):
     assert response.json() == snapshot(
         {
             "detail": [
-                IsDict(
-                    {
-                        "type": "extra_forbidden",
-                        "loc": ["query", "tool"],
-                        "msg": "Extra inputs are not permitted",
-                        "input": "plumbus",
-                    }
-                )
-                | IsDict(
-                    # TODO: remove when deprecating Pydantic v1
-                    {
-                        "type": "value_error.extra",
-                        "loc": ["query", "tool"],
-                        "msg": "extra fields not permitted",
-                    }
-                )
+                {
+                    "type": "extra_forbidden",
+                    "loc": ["query", "tool"],
+                    "msg": "Extra inputs are not permitted",
+                    "input": "plumbus",
+                }
             ]
         }
     )
index ad4e4efa6b11fa464d3e6794e951e4b65c4a4d12..10307814720d70ea7aff604d709f5e5c94fc9be9 100644 (file)
@@ -1,4 +1,3 @@
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from docs_src.query_params.tutorial005_py39 import app
@@ -15,29 +14,16 @@ def test_foo_needy_very():
 def test_foo_no_needy():
     response = client.get("/items/foo")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "needy"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "needy"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "needy"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_openapi_schema():
index 349f8dd223f6cd93f11e4281478fe2bd2907595b..157322c7e318ea5ead2bdcbbbda47ab9d171b1d6 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
@@ -35,51 +34,28 @@ def test_foo_needy_very(client: TestClient):
 def test_foo_no_needy(client: TestClient):
     response = client.get("/items/foo?skip=a&limit=b")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["query", "needy"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "int_parsing",
-                    "loc": ["query", "skip"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "a",
-                },
-                {
-                    "type": "int_parsing",
-                    "loc": ["query", "limit"],
-                    "msg": "Input should be a valid integer, unable to parse string as an integer",
-                    "input": "b",
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["query", "needy"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["query", "skip"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                },
-                {
-                    "loc": ["query", "limit"],
-                    "msg": "value is not a valid integer",
-                    "type": "type_error.integer",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["query", "needy"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "int_parsing",
+                "loc": ["query", "skip"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "a",
+            },
+            {
+                "type": "int_parsing",
+                "loc": ["query", "limit"],
+                "msg": "Input should be a valid integer, unable to parse string as an integer",
+                "input": "b",
+            },
+        ]
+    }
 
 
 def test_openapi_schema(client: TestClient):
@@ -134,16 +110,10 @@ def test_openapi_schema(client: TestClient):
                         },
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [{"type": "integer"}, {"type": "null"}],
-                                    "title": "Limit",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {"title": "Limit", "type": "integer"}
-                            ),
+                            "schema": {
+                                "anyOf": [{"type": "integer"}, {"type": "null"}],
+                                "title": "Limit",
+                            },
                             "name": "limit",
                             "in": "query",
                         },
index de5dbbb2ee7af7234fadd799acd5ec0aed6501e9..00889c5bf77dc8ed6b654d40eb2b48f14111bf61 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi._compat import PYDANTIC_VERSION_MINOR_TUPLE
 from fastapi.testclient import TestClient
 
@@ -50,31 +49,17 @@ def test_query_params_str_validations_q_fixedquery(client: TestClient):
 def test_query_params_str_validations_item_query_nonregexquery(client: TestClient):
     response = client.get("/items/", params={"item-query": "nonregexquery"})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "string_pattern_mismatch",
-                    "loc": ["query", "item-query"],
-                    "msg": "String should match pattern '^fixedquery$'",
-                    "input": "nonregexquery",
-                    "ctx": {"pattern": "^fixedquery$"},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "ctx": {"pattern": "^fixedquery$"},
-                    "loc": ["query", "item-query"],
-                    "msg": 'string does not match regex "^fixedquery$"',
-                    "type": "value_error.str.regex",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "string_pattern_mismatch",
+                "loc": ["query", "item-query"],
+                "msg": "String should match pattern '^fixedquery$'",
+                "input": "nonregexquery",
+                "ctx": {"pattern": "^fixedquery$"},
+            }
+        ]
+    }
 
 
 def test_openapi_schema(client: TestClient):
@@ -109,38 +94,25 @@ def test_openapi_schema(client: TestClient):
                             "description": "Query string for the items to search in the database that have a good match",
                             "required": False,
                             "deprecated": True,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [
-                                        {
-                                            "type": "string",
-                                            "minLength": 3,
-                                            "maxLength": 50,
-                                            "pattern": "^fixedquery$",
-                                        },
-                                        {"type": "null"},
-                                    ],
-                                    "title": "Query string",
-                                    "description": "Query string for the items to search in the database that have a good match",
-                                    # See https://github.com/pydantic/pydantic/blob/80353c29a824c55dea4667b328ba8f329879ac9f/tests/test_fastapi.sh#L25-L34.
-                                    **(
-                                        {"deprecated": True}
-                                        if PYDANTIC_VERSION_MINOR_TUPLE >= (2, 10)
-                                        else {}
-                                    ),
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {
-                                    "title": "Query string",
-                                    "maxLength": 50,
-                                    "minLength": 3,
-                                    "pattern": "^fixedquery$",
-                                    "type": "string",
-                                    "description": "Query string for the items to search in the database that have a good match",
-                                }
-                            ),
+                            "schema": {
+                                "anyOf": [
+                                    {
+                                        "type": "string",
+                                        "minLength": 3,
+                                        "maxLength": 50,
+                                        "pattern": "^fixedquery$",
+                                    },
+                                    {"type": "null"},
+                                ],
+                                "title": "Query string",
+                                "description": "Query string for the items to search in the database that have a good match",
+                                # See https://github.com/pydantic/pydantic/blob/80353c29a824c55dea4667b328ba8f329879ac9f/tests/test_fastapi.sh#L25-L34.
+                                **(
+                                    {"deprecated": True}
+                                    if PYDANTIC_VERSION_MINOR_TUPLE >= (2, 10)
+                                    else {}
+                                ),
+                            },
                             "name": "item-query",
                             "in": "query",
                         }
index 50b3c5683cb44f97067a3e0368ebbb148591ee09..11de33ae14f5c16cb04a0212db8ad7979a461869 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
@@ -69,23 +68,13 @@ def test_openapi_schema(client: TestClient):
                     "parameters": [
                         {
                             "required": False,
-                            "schema": IsDict(
-                                {
-                                    "anyOf": [
-                                        {"type": "array", "items": {"type": "string"}},
-                                        {"type": "null"},
-                                    ],
-                                    "title": "Q",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {
-                                    "title": "Q",
-                                    "type": "array",
-                                    "items": {"type": "string"},
-                                }
-                            ),
+                            "schema": {
+                                "anyOf": [
+                                    {"type": "array", "items": {"type": "string"}},
+                                    {"type": "null"},
+                                ],
+                                "title": "Q",
+                            },
                             "name": "q",
                             "in": "query",
                         }
index a16d951dc6cd78e3c4c945104e0dac3101d0e11c..e0e1bbe639f9bafc1fe9a7d4d109163c74ffec57 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 
@@ -22,57 +21,31 @@ def get_client(request: pytest.FixtureRequest):
 def test_post_form_no_body(client: TestClient):
     response = client.post("/files/")
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "file"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "file"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "file"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_post_body_json(client: TestClient):
     response = client.post("/files/", json={"file": "Foo"})
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "file"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "file"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "file"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_post_file(tmp_path, client: TestClient):
index caea0d2e8fc9161d850b1ce3f5955fa8e513db65..18948c544422487d4412da63de4463b2e9a07db6 100644 (file)
@@ -2,8 +2,8 @@ import importlib
 from pathlib import Path
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
 
 from ...utils import needs_py310
 
@@ -59,166 +59,132 @@ def test_post_upload_file(tmp_path: Path, client: TestClient):
 def test_openapi_schema(client: TestClient):
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/files/": {
-                "post": {
-                    "summary": "Create File",
-                    "operationId": "create_file_files__post",
-                    "requestBody": {
-                        "content": {
-                            "multipart/form-data": {
-                                "schema": IsDict(
-                                    {
-                                        "allOf": [
-                                            {
-                                                "$ref": "#/components/schemas/Body_create_file_files__post"
-                                            }
-                                        ],
-                                        "title": "Body",
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {
+    assert response.json() == snapshot(
+        {
+            "openapi": "3.1.0",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "paths": {
+                "/files/": {
+                    "post": {
+                        "summary": "Create File",
+                        "operationId": "create_file_files__post",
+                        "requestBody": {
+                            "content": {
+                                "multipart/form-data": {
+                                    "schema": {
                                         "$ref": "#/components/schemas/Body_create_file_files__post"
                                     }
-                                )
+                                }
                             }
-                        }
-                    },
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
                         },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {"application/json": {"schema": {}}},
+                            },
+                            "422": {
+                                "description": "Validation Error",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/HTTPValidationError"
+                                        }
                                     }
-                                }
+                                },
                             },
                         },
-                    },
-                }
-            },
-            "/uploadfile/": {
-                "post": {
-                    "summary": "Create Upload File",
-                    "operationId": "create_upload_file_uploadfile__post",
-                    "requestBody": {
-                        "content": {
-                            "multipart/form-data": {
-                                "schema": IsDict(
-                                    {
-                                        "allOf": [
-                                            {
-                                                "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
-                                            }
-                                        ],
-                                        "title": "Body",
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {
+                    }
+                },
+                "/uploadfile/": {
+                    "post": {
+                        "summary": "Create Upload File",
+                        "operationId": "create_upload_file_uploadfile__post",
+                        "requestBody": {
+                            "content": {
+                                "multipart/form-data": {
+                                    "schema": {
                                         "$ref": "#/components/schemas/Body_create_upload_file_uploadfile__post"
                                     }
-                                )
+                                }
                             }
-                        }
-                    },
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
                         },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {"application/json": {"schema": {}}},
+                            },
+                            "422": {
+                                "description": "Validation Error",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/HTTPValidationError"
+                                        }
                                     }
-                                }
+                                },
                             },
                         },
-                    },
-                }
+                    }
+                },
             },
-        },
-        "components": {
-            "schemas": {
-                "Body_create_file_files__post": {
-                    "title": "Body_create_file_files__post",
-                    "type": "object",
-                    "properties": {
-                        "file": IsDict(
-                            {
+            "components": {
+                "schemas": {
+                    "Body_create_file_files__post": {
+                        "title": "Body_create_file_files__post",
+                        "type": "object",
+                        "properties": {
+                            "file": {
                                 "title": "File",
                                 "anyOf": [
                                     {"type": "string", "format": "binary"},
                                     {"type": "null"},
                                 ],
                             }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "File", "type": "string", "format": "binary"}
-                        )
+                        },
                     },
-                },
-                "Body_create_upload_file_uploadfile__post": {
-                    "title": "Body_create_upload_file_uploadfile__post",
-                    "type": "object",
-                    "properties": {
-                        "file": IsDict(
-                            {
+                    "Body_create_upload_file_uploadfile__post": {
+                        "title": "Body_create_upload_file_uploadfile__post",
+                        "type": "object",
+                        "properties": {
+                            "file": {
                                 "title": "File",
                                 "anyOf": [
                                     {"type": "string", "format": "binary"},
                                     {"type": "null"},
                                 ],
                             }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "File", "type": "string", "format": "binary"}
-                        )
+                        },
                     },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
+                    "HTTPValidationError": {
+                        "title": "HTTPValidationError",
+                        "type": "object",
+                        "properties": {
+                            "detail": {
+                                "title": "Detail",
+                                "type": "array",
+                                "items": {
+                                    "$ref": "#/components/schemas/ValidationError"
+                                },
+                            }
+                        },
                     },
-                },
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                    "ValidationError": {
+                        "title": "ValidationError",
+                        "required": ["loc", "msg", "type"],
+                        "type": "object",
+                        "properties": {
+                            "loc": {
+                                "title": "Location",
+                                "type": "array",
+                                "items": {
+                                    "anyOf": [{"type": "string"}, {"type": "integer"}]
+                                },
                             },
+                            "msg": {"title": "Message", "type": "string"},
+                            "type": {"title": "Error Type", "type": "string"},
                         },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
                     },
-                },
-            }
-        },
-    }
+                }
+            },
+        }
+    )
index 34dbbb985dae4b5064e212c9da42901ed28ebbd0..03772419ad2425a5710f4ffa1188b81341d0b7d2 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import FastAPI
 from fastapi.testclient import TestClient
 
@@ -28,57 +27,31 @@ def get_client(app: FastAPI):
 def test_post_form_no_body(client: TestClient):
     response = client.post("/files/")
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "files"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "files"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "files"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_post_body_json(client: TestClient):
     response = client.post("/files/", json={"file": "Foo"})
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "files"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "files"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "files"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_post_files(tmp_path, app: FastAPI):
index a54df8536c0f60455ff2388c54acbd27fb91d12e..0c43dd7b2111ea45bbcc4bddd3c648886eba1727 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 
@@ -28,135 +27,73 @@ def test_post_body_form(client: TestClient):
 def test_post_body_form_no_password(client: TestClient):
     response = client.post("/login/", data={"username": "Foo"})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "password"],
-                    "msg": "Field required",
-                    "input": {"username": "Foo"},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "password"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "password"],
+                "msg": "Field required",
+                "input": {"username": "Foo"},
+            }
+        ]
+    }
 
 
 def test_post_body_form_no_username(client: TestClient):
     response = client.post("/login/", data={"password": "secret"})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "username"],
-                    "msg": "Field required",
-                    "input": {"password": "secret"},
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "username"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "username"],
+                "msg": "Field required",
+                "input": {"password": "secret"},
+            }
+        ]
+    }
 
 
 def test_post_body_form_no_data(client: TestClient):
     response = client.post("/login/")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "username"],
-                    "msg": "Field required",
-                    "input": {},
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "password"],
-                    "msg": "Field required",
-                    "input": {},
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "username"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "password"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "username"],
+                "msg": "Field required",
+                "input": {},
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "password"],
+                "msg": "Field required",
+                "input": {},
+            },
+        ]
+    }
 
 
 def test_post_body_json(client: TestClient):
     response = client.post("/login/", json={"username": "Foo", "password": "secret"})
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "username"],
-                    "msg": "Field required",
-                    "input": {},
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "password"],
-                    "msg": "Field required",
-                    "input": {},
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "username"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "password"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "username"],
+                "msg": "Field required",
+                "input": {},
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "password"],
+                "msg": "Field required",
+                "input": {},
+            },
+        ]
+    }
 
 
 def test_openapi_schema(client: TestClient):
index da20535cf883ca7c450f00b5e99a0de8bdc0024f..4276414fc2143352f53b9870c2253828f770c213 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 
@@ -28,135 +27,73 @@ def test_post_body_form(client: TestClient):
 def test_post_body_form_no_password(client: TestClient):
     response = client.post("/login/", data={"username": "Foo"})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "password"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "password"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "password"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_post_body_form_no_username(client: TestClient):
     response = client.post("/login/", data={"password": "secret"})
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "username"],
-                    "msg": "Field required",
-                    "input": None,
-                }
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "username"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                }
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "username"],
+                "msg": "Field required",
+                "input": None,
+            }
+        ]
+    }
 
 
 def test_post_body_form_no_data(client: TestClient):
     response = client.post("/login/")
     assert response.status_code == 422
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "username"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "password"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "username"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "password"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "username"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "password"],
+                "msg": "Field required",
+                "input": None,
+            },
+        ]
+    }
 
 
 def test_post_body_json(client: TestClient):
     response = client.post("/login/", json={"username": "Foo", "password": "secret"})
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "username"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "password"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "username"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "password"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "username"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "password"],
+                "msg": "Field required",
+                "input": None,
+            },
+        ]
+    }
 
 
 def test_openapi_schema(client: TestClient):
index f37ffad44337b5be9f4aaf9530eff1da2ed914b0..7fa4c3de57d4bcb76d767f0d1d826d78fa63cdd6 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi import FastAPI
 from fastapi.testclient import TestClient
 
@@ -28,140 +27,76 @@ def get_client(app: FastAPI):
 def test_post_form_no_body(client: TestClient):
     response = client.post("/files/")
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "file"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "fileb"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "token"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "file"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "fileb"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "file"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "fileb"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "token"],
+                "msg": "Field required",
+                "input": None,
+            },
+        ]
+    }
 
 
 def test_post_form_no_file(client: TestClient):
     response = client.post("/files/", data={"token": "foo"})
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "file"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "fileb"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "file"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "fileb"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "file"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "fileb"],
+                "msg": "Field required",
+                "input": None,
+            },
+        ]
+    }
 
 
 def test_post_body_json(client: TestClient):
     response = client.post("/files/", json={"file": "Foo", "token": "Bar"})
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "file"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "fileb"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "token"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "file"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "fileb"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "file"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "fileb"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "token"],
+                "msg": "Field required",
+                "input": None,
+            },
+        ]
+    }
 
 
 def test_post_file_no_token(tmp_path, app: FastAPI):
@@ -172,40 +107,22 @@ def test_post_file_no_token(tmp_path, app: FastAPI):
     with path.open("rb") as file:
         response = client.post("/files/", files={"file": file})
     assert response.status_code == 422, response.text
-    assert response.json() == IsDict(
-        {
-            "detail": [
-                {
-                    "type": "missing",
-                    "loc": ["body", "fileb"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-                {
-                    "type": "missing",
-                    "loc": ["body", "token"],
-                    "msg": "Field required",
-                    "input": None,
-                },
-            ]
-        }
-    ) | IsDict(
-        # TODO: remove when deprecating Pydantic v1
-        {
-            "detail": [
-                {
-                    "loc": ["body", "fileb"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-                {
-                    "loc": ["body", "token"],
-                    "msg": "field required",
-                    "type": "value_error.missing",
-                },
-            ]
-        }
-    )
+    assert response.json() == {
+        "detail": [
+            {
+                "type": "missing",
+                "loc": ["body", "fileb"],
+                "msg": "Field required",
+                "input": None,
+            },
+            {
+                "type": "missing",
+                "loc": ["body", "token"],
+                "msg": "Field required",
+                "input": None,
+            },
+        ]
+    }
 
 
 def test_post_files_and_token(tmp_path, app: FastAPI):
index 0f9eac890b41a1a50a8d982b5e5f760154300cae..35ed5572dd8928bac4a404167655034351b41b75 100644 (file)
@@ -1,8 +1,8 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict, IsOneOf
 from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
 
 from ...utils import needs_py310
 
@@ -42,125 +42,115 @@ def test_post_user(client: TestClient):
 def test_openapi_schema(client: TestClient):
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/user/": {
-                "post": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {
-                                "application/json": {
-                                    "schema": {"$ref": "#/components/schemas/UserOut"}
-                                }
+    assert response.json() == snapshot(
+        {
+            "openapi": "3.1.0",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "paths": {
+                "/user/": {
+                    "post": {
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/UserOut"
+                                        }
+                                    }
+                                },
+                            },
+                            "422": {
+                                "description": "Validation Error",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/HTTPValidationError"
+                                        }
+                                    }
+                                },
                             },
                         },
-                        "422": {
-                            "description": "Validation Error",
+                        "summary": "Create User",
+                        "operationId": "create_user_user__post",
+                        "requestBody": {
                             "content": {
                                 "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
-                                    }
+                                    "schema": {"$ref": "#/components/schemas/UserIn"}
                                 }
                             },
+                            "required": True,
                         },
-                    },
-                    "summary": "Create User",
-                    "operationId": "create_user_user__post",
-                    "requestBody": {
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/UserIn"}
-                            }
-                        },
-                        "required": True,
-                    },
+                    }
                 }
-            }
-        },
-        "components": {
-            "schemas": {
-                "UserOut": {
-                    "title": "UserOut",
-                    "required": IsOneOf(
-                        ["username", "email", "full_name"],
-                        # TODO: remove when deprecating Pydantic v1
-                        ["username", "email"],
-                    ),
-                    "type": "object",
-                    "properties": {
-                        "username": {"title": "Username", "type": "string"},
-                        "email": {
-                            "title": "Email",
-                            "type": "string",
-                            "format": "email",
-                        },
-                        "full_name": IsDict(
-                            {
+            },
+            "components": {
+                "schemas": {
+                    "UserOut": {
+                        "title": "UserOut",
+                        "required": ["username", "email"],
+                        "type": "object",
+                        "properties": {
+                            "username": {"title": "Username", "type": "string"},
+                            "email": {
+                                "title": "Email",
+                                "type": "string",
+                                "format": "email",
+                            },
+                            "full_name": {
                                 "title": "Full Name",
                                 "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Full Name", "type": "string"}
-                        ),
-                    },
-                },
-                "UserIn": {
-                    "title": "UserIn",
-                    "required": ["username", "password", "email"],
-                    "type": "object",
-                    "properties": {
-                        "username": {"title": "Username", "type": "string"},
-                        "password": {"title": "Password", "type": "string"},
-                        "email": {
-                            "title": "Email",
-                            "type": "string",
-                            "format": "email",
+                            },
                         },
-                        "full_name": IsDict(
-                            {
+                    },
+                    "UserIn": {
+                        "title": "UserIn",
+                        "required": ["username", "password", "email"],
+                        "type": "object",
+                        "properties": {
+                            "username": {"title": "Username", "type": "string"},
+                            "password": {"title": "Password", "type": "string"},
+                            "email": {
+                                "title": "Email",
+                                "type": "string",
+                                "format": "email",
+                            },
+                            "full_name": {
                                 "title": "Full Name",
                                 "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Full Name", "type": "string"}
-                        ),
+                            },
+                        },
                     },
-                },
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                    "ValidationError": {
+                        "title": "ValidationError",
+                        "required": ["loc", "msg", "type"],
+                        "type": "object",
+                        "properties": {
+                            "loc": {
+                                "title": "Location",
+                                "type": "array",
+                                "items": {
+                                    "anyOf": [{"type": "string"}, {"type": "integer"}]
+                                },
                             },
+                            "msg": {"title": "Message", "type": "string"},
+                            "type": {"title": "Error Type", "type": "string"},
                         },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
                     },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
+                    "HTTPValidationError": {
+                        "title": "HTTPValidationError",
+                        "type": "object",
+                        "properties": {
+                            "detail": {
+                                "title": "Detail",
+                                "type": "array",
+                                "items": {
+                                    "$ref": "#/components/schemas/ValidationError"
+                                },
+                            }
+                        },
                     },
-                },
-            }
-        },
-    }
+                }
+            },
+        }
+    )
index 1a7ce4c7a1e2b5394d1820aba4ce6260830d4080..fa1eb627706961bbe6504d74377a647b8602e16e 100644 (file)
@@ -1,8 +1,8 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict, IsOneOf
 from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
 
 from ...utils import needs_py310
 
@@ -42,125 +42,115 @@ def test_post_user(client: TestClient):
 def test_openapi_schema(client: TestClient):
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/user/": {
-                "post": {
-                    "summary": "Create User",
-                    "operationId": "create_user_user__post",
-                    "requestBody": {
-                        "content": {
-                            "application/json": {
-                                "schema": {"$ref": "#/components/schemas/UserIn"}
-                            }
-                        },
-                        "required": True,
-                    },
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
+    assert response.json() == snapshot(
+        {
+            "openapi": "3.1.0",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "paths": {
+                "/user/": {
+                    "post": {
+                        "summary": "Create User",
+                        "operationId": "create_user_user__post",
+                        "requestBody": {
                             "content": {
                                 "application/json": {
-                                    "schema": {"$ref": "#/components/schemas/BaseUser"}
+                                    "schema": {"$ref": "#/components/schemas/UserIn"}
                                 }
                             },
+                            "required": True,
                         },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/BaseUser"
+                                        }
                                     }
-                                }
+                                },
+                            },
+                            "422": {
+                                "description": "Validation Error",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/HTTPValidationError"
+                                        }
+                                    }
+                                },
                             },
                         },
-                    },
+                    }
                 }
-            }
-        },
-        "components": {
-            "schemas": {
-                "BaseUser": {
-                    "title": "BaseUser",
-                    "required": IsOneOf(
-                        ["username", "email", "full_name"],
-                        # TODO: remove when deprecating Pydantic v1
-                        ["username", "email"],
-                    ),
-                    "type": "object",
-                    "properties": {
-                        "username": {"title": "Username", "type": "string"},
-                        "email": {
-                            "title": "Email",
-                            "type": "string",
-                            "format": "email",
-                        },
-                        "full_name": IsDict(
-                            {
+            },
+            "components": {
+                "schemas": {
+                    "BaseUser": {
+                        "title": "BaseUser",
+                        "required": ["username", "email"],
+                        "type": "object",
+                        "properties": {
+                            "username": {"title": "Username", "type": "string"},
+                            "email": {
+                                "title": "Email",
+                                "type": "string",
+                                "format": "email",
+                            },
+                            "full_name": {
                                 "title": "Full Name",
                                 "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Full Name", "type": "string"}
-                        ),
-                    },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
+                            },
+                        },
                     },
-                },
-                "UserIn": {
-                    "title": "UserIn",
-                    "required": ["username", "email", "password"],
-                    "type": "object",
-                    "properties": {
-                        "username": {"title": "Username", "type": "string"},
-                        "email": {
-                            "title": "Email",
-                            "type": "string",
-                            "format": "email",
+                    "HTTPValidationError": {
+                        "title": "HTTPValidationError",
+                        "type": "object",
+                        "properties": {
+                            "detail": {
+                                "title": "Detail",
+                                "type": "array",
+                                "items": {
+                                    "$ref": "#/components/schemas/ValidationError"
+                                },
+                            }
                         },
-                        "full_name": IsDict(
-                            {
+                    },
+                    "UserIn": {
+                        "title": "UserIn",
+                        "required": ["username", "email", "password"],
+                        "type": "object",
+                        "properties": {
+                            "username": {"title": "Username", "type": "string"},
+                            "email": {
+                                "title": "Email",
+                                "type": "string",
+                                "format": "email",
+                            },
+                            "full_name": {
                                 "title": "Full Name",
                                 "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Full Name", "type": "string"}
-                        ),
-                        "password": {"title": "Password", "type": "string"},
+                            },
+                            "password": {"title": "Password", "type": "string"},
+                        },
                     },
-                },
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                    "ValidationError": {
+                        "title": "ValidationError",
+                        "required": ["loc", "msg", "type"],
+                        "type": "object",
+                        "properties": {
+                            "loc": {
+                                "title": "Location",
+                                "type": "array",
+                                "items": {
+                                    "anyOf": [{"type": "string"}, {"type": "integer"}]
+                                },
                             },
+                            "msg": {"title": "Message", "type": "string"},
+                            "type": {"title": "Error Type", "type": "string"},
                         },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
                     },
-                },
-            }
-        },
-    }
+                }
+            },
+        }
+    )
index 19f6998f70b585166863e131f89fc8493cbcf584..9c0d95ebd043dbbe5e2808035cc940c1b9eae1d2 100644 (file)
@@ -1,8 +1,8 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict, IsOneOf
 from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
 
 from ...utils import needs_py310
 
@@ -50,104 +50,98 @@ def test_get(url, data, client: TestClient):
 def test_openapi_schema(client: TestClient):
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/{item_id}": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {
-                                "application/json": {
-                                    "schema": {"$ref": "#/components/schemas/Item"}
-                                }
+    assert response.json() == snapshot(
+        {
+            "openapi": "3.1.0",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "paths": {
+                "/items/{item_id}": {
+                    "get": {
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {"$ref": "#/components/schemas/Item"}
+                                    }
+                                },
                             },
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
+                            "422": {
+                                "description": "Validation Error",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/HTTPValidationError"
+                                        }
                                     }
-                                }
+                                },
                             },
                         },
-                    },
-                    "summary": "Read Item",
-                    "operationId": "read_item_items__item_id__get",
-                    "parameters": [
-                        {
-                            "required": True,
-                            "schema": {"title": "Item Id", "type": "string"},
-                            "name": "item_id",
-                            "in": "path",
-                        }
-                    ],
-                }
-            }
-        },
-        "components": {
-            "schemas": {
-                "Item": {
-                    "title": "Item",
-                    "required": IsOneOf(
-                        ["name", "description", "price", "tax", "tags"],
-                        # TODO: remove when deprecating Pydantic v1
-                        ["name", "price"],
-                    ),
-                    "type": "object",
-                    "properties": {
-                        "name": {"title": "Name", "type": "string"},
-                        "price": {"title": "Price", "type": "number"},
-                        "description": IsDict(
+                        "summary": "Read Item",
+                        "operationId": "read_item_items__item_id__get",
+                        "parameters": [
                             {
+                                "required": True,
+                                "schema": {"title": "Item Id", "type": "string"},
+                                "name": "item_id",
+                                "in": "path",
+                            }
+                        ],
+                    }
+                }
+            },
+            "components": {
+                "schemas": {
+                    "Item": {
+                        "title": "Item",
+                        "required": ["name", "price"],
+                        "type": "object",
+                        "properties": {
+                            "name": {"title": "Name", "type": "string"},
+                            "price": {"title": "Price", "type": "number"},
+                            "description": {
                                 "title": "Description",
                                 "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Description", "type": "string"}
-                        ),
-                        "tax": {"title": "Tax", "type": "number", "default": 10.5},
-                        "tags": {
-                            "title": "Tags",
-                            "type": "array",
-                            "items": {"type": "string"},
-                            "default": [],
+                            },
+                            "tax": {"title": "Tax", "type": "number", "default": 10.5},
+                            "tags": {
+                                "title": "Tags",
+                                "type": "array",
+                                "items": {"type": "string"},
+                                "default": [],
+                            },
                         },
                     },
-                },
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                    "ValidationError": {
+                        "title": "ValidationError",
+                        "required": ["loc", "msg", "type"],
+                        "type": "object",
+                        "properties": {
+                            "loc": {
+                                "title": "Location",
+                                "type": "array",
+                                "items": {
+                                    "anyOf": [{"type": "string"}, {"type": "integer"}]
+                                },
                             },
+                            "msg": {"title": "Message", "type": "string"},
+                            "type": {"title": "Error Type", "type": "string"},
                         },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
                     },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
+                    "HTTPValidationError": {
+                        "title": "HTTPValidationError",
+                        "type": "object",
+                        "properties": {
+                            "detail": {
+                                "title": "Detail",
+                                "type": "array",
+                                "items": {
+                                    "$ref": "#/components/schemas/ValidationError"
+                                },
+                            }
+                        },
                     },
-                },
-            }
-        },
-    }
+                }
+            },
+        }
+    )
index 47d77dc4988e5dd52603fd2ad9bbab6e05a2bcc5..63e8535db0e3a49d36d69208929c6ffd5b5f561d 100644 (file)
@@ -1,8 +1,8 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict, IsOneOf
 from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
 
 from ...utils import needs_py310
 
@@ -40,132 +40,126 @@ def test_read_item_public_data(client: TestClient):
 def test_openapi_schema(client: TestClient):
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/{item_id}/name": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {
-                                "application/json": {
-                                    "schema": {"$ref": "#/components/schemas/Item"}
-                                }
+    assert response.json() == snapshot(
+        {
+            "openapi": "3.1.0",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "paths": {
+                "/items/{item_id}/name": {
+                    "get": {
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {"$ref": "#/components/schemas/Item"}
+                                    }
+                                },
                             },
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
+                            "422": {
+                                "description": "Validation Error",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/HTTPValidationError"
+                                        }
                                     }
-                                }
+                                },
                             },
                         },
-                    },
-                    "summary": "Read Item Name",
-                    "operationId": "read_item_name_items__item_id__name_get",
-                    "parameters": [
-                        {
-                            "required": True,
-                            "schema": {"title": "Item Id", "type": "string"},
-                            "name": "item_id",
-                            "in": "path",
-                        }
-                    ],
-                }
-            },
-            "/items/{item_id}/public": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {
-                                "application/json": {
-                                    "schema": {"$ref": "#/components/schemas/Item"}
-                                }
+                        "summary": "Read Item Name",
+                        "operationId": "read_item_name_items__item_id__name_get",
+                        "parameters": [
+                            {
+                                "required": True,
+                                "schema": {"title": "Item Id", "type": "string"},
+                                "name": "item_id",
+                                "in": "path",
+                            }
+                        ],
+                    }
+                },
+                "/items/{item_id}/public": {
+                    "get": {
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {"$ref": "#/components/schemas/Item"}
+                                    }
+                                },
                             },
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
+                            "422": {
+                                "description": "Validation Error",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/HTTPValidationError"
+                                        }
                                     }
-                                }
+                                },
                             },
                         },
-                    },
-                    "summary": "Read Item Public Data",
-                    "operationId": "read_item_public_data_items__item_id__public_get",
-                    "parameters": [
-                        {
-                            "required": True,
-                            "schema": {"title": "Item Id", "type": "string"},
-                            "name": "item_id",
-                            "in": "path",
-                        }
-                    ],
-                }
-            },
-        },
-        "components": {
-            "schemas": {
-                "Item": {
-                    "title": "Item",
-                    "required": IsOneOf(
-                        ["name", "description", "price", "tax"],
-                        # TODO: remove when deprecating Pydantic v1
-                        ["name", "price"],
-                    ),
-                    "type": "object",
-                    "properties": {
-                        "name": {"title": "Name", "type": "string"},
-                        "price": {"title": "Price", "type": "number"},
-                        "description": IsDict(
+                        "summary": "Read Item Public Data",
+                        "operationId": "read_item_public_data_items__item_id__public_get",
+                        "parameters": [
                             {
+                                "required": True,
+                                "schema": {"title": "Item Id", "type": "string"},
+                                "name": "item_id",
+                                "in": "path",
+                            }
+                        ],
+                    }
+                },
+            },
+            "components": {
+                "schemas": {
+                    "Item": {
+                        "title": "Item",
+                        "required": ["name", "price"],
+                        "type": "object",
+                        "properties": {
+                            "name": {"title": "Name", "type": "string"},
+                            "price": {"title": "Price", "type": "number"},
+                            "description": {
                                 "title": "Description",
                                 "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Description", "type": "string"}
-                        ),
-                        "tax": {"title": "Tax", "type": "number", "default": 10.5},
+                            },
+                            "tax": {"title": "Tax", "type": "number", "default": 10.5},
+                        },
                     },
-                },
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                    "ValidationError": {
+                        "title": "ValidationError",
+                        "required": ["loc", "msg", "type"],
+                        "type": "object",
+                        "properties": {
+                            "loc": {
+                                "title": "Location",
+                                "type": "array",
+                                "items": {
+                                    "anyOf": [{"type": "string"}, {"type": "integer"}]
+                                },
                             },
+                            "msg": {"title": "Message", "type": "string"},
+                            "type": {"title": "Error Type", "type": "string"},
                         },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
                     },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
+                    "HTTPValidationError": {
+                        "title": "HTTPValidationError",
+                        "type": "object",
+                        "properties": {
+                            "detail": {
+                                "title": "Detail",
+                                "type": "array",
+                                "items": {
+                                    "$ref": "#/components/schemas/ValidationError"
+                                },
+                            }
+                        },
                     },
-                },
-            }
-        },
-    }
+                }
+            },
+        }
+    )
index a03aa41e8cc91f5f057163c0f89ec44109401135..08ab659527e8da40d7a0cb546493578628a3d646 100644 (file)
@@ -1,8 +1,8 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict, IsOneOf
 from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
 
 from ...utils import needs_py310
 
@@ -40,132 +40,126 @@ def test_read_item_public_data(client: TestClient):
 def test_openapi_schema(client: TestClient):
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/items/{item_id}/name": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {
-                                "application/json": {
-                                    "schema": {"$ref": "#/components/schemas/Item"}
-                                }
+    assert response.json() == snapshot(
+        {
+            "openapi": "3.1.0",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "paths": {
+                "/items/{item_id}/name": {
+                    "get": {
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {"$ref": "#/components/schemas/Item"}
+                                    }
+                                },
                             },
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
+                            "422": {
+                                "description": "Validation Error",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/HTTPValidationError"
+                                        }
                                     }
-                                }
+                                },
                             },
                         },
-                    },
-                    "summary": "Read Item Name",
-                    "operationId": "read_item_name_items__item_id__name_get",
-                    "parameters": [
-                        {
-                            "required": True,
-                            "schema": {"title": "Item Id", "type": "string"},
-                            "name": "item_id",
-                            "in": "path",
-                        }
-                    ],
-                }
-            },
-            "/items/{item_id}/public": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {
-                                "application/json": {
-                                    "schema": {"$ref": "#/components/schemas/Item"}
-                                }
+                        "summary": "Read Item Name",
+                        "operationId": "read_item_name_items__item_id__name_get",
+                        "parameters": [
+                            {
+                                "required": True,
+                                "schema": {"title": "Item Id", "type": "string"},
+                                "name": "item_id",
+                                "in": "path",
+                            }
+                        ],
+                    }
+                },
+                "/items/{item_id}/public": {
+                    "get": {
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {"$ref": "#/components/schemas/Item"}
+                                    }
+                                },
                             },
-                        },
-                        "422": {
-                            "description": "Validation Error",
-                            "content": {
-                                "application/json": {
-                                    "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
+                            "422": {
+                                "description": "Validation Error",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/HTTPValidationError"
+                                        }
                                     }
-                                }
+                                },
                             },
                         },
-                    },
-                    "summary": "Read Item Public Data",
-                    "operationId": "read_item_public_data_items__item_id__public_get",
-                    "parameters": [
-                        {
-                            "required": True,
-                            "schema": {"title": "Item Id", "type": "string"},
-                            "name": "item_id",
-                            "in": "path",
-                        }
-                    ],
-                }
-            },
-        },
-        "components": {
-            "schemas": {
-                "Item": {
-                    "title": "Item",
-                    "required": IsOneOf(
-                        ["name", "description", "price", "tax"],
-                        # TODO: remove when deprecating Pydantic v1
-                        ["name", "price"],
-                    ),
-                    "type": "object",
-                    "properties": {
-                        "name": {"title": "Name", "type": "string"},
-                        "price": {"title": "Price", "type": "number"},
-                        "description": IsDict(
+                        "summary": "Read Item Public Data",
+                        "operationId": "read_item_public_data_items__item_id__public_get",
+                        "parameters": [
                             {
+                                "required": True,
+                                "schema": {"title": "Item Id", "type": "string"},
+                                "name": "item_id",
+                                "in": "path",
+                            }
+                        ],
+                    }
+                },
+            },
+            "components": {
+                "schemas": {
+                    "Item": {
+                        "title": "Item",
+                        "required": ["name", "price"],
+                        "type": "object",
+                        "properties": {
+                            "name": {"title": "Name", "type": "string"},
+                            "price": {"title": "Price", "type": "number"},
+                            "description": {
                                 "title": "Description",
                                 "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Description", "type": "string"}
-                        ),
-                        "tax": {"title": "Tax", "type": "number", "default": 10.5},
+                            },
+                            "tax": {"title": "Tax", "type": "number", "default": 10.5},
+                        },
                     },
-                },
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                    "ValidationError": {
+                        "title": "ValidationError",
+                        "required": ["loc", "msg", "type"],
+                        "type": "object",
+                        "properties": {
+                            "loc": {
+                                "title": "Location",
+                                "type": "array",
+                                "items": {
+                                    "anyOf": [{"type": "string"}, {"type": "integer"}]
+                                },
                             },
+                            "msg": {"title": "Message", "type": "string"},
+                            "type": {"title": "Error Type", "type": "string"},
                         },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
                     },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
+                    "HTTPValidationError": {
+                        "title": "HTTPValidationError",
+                        "type": "object",
+                        "properties": {
+                            "detail": {
+                                "title": "Detail",
+                                "type": "array",
+                                "items": {
+                                    "$ref": "#/components/schemas/ValidationError"
+                                },
+                            }
+                        },
                     },
-                },
-            }
-        },
-    }
+                }
+            },
+        }
+    )
index 47ecb9ba7372fc69d6f94286703f98b6164c3056..9326e06290b400a7f130f0613c1fd9849cdac5ac 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
@@ -58,46 +57,22 @@ def test_openapi_schema(client: TestClient):
                     "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": IsDict(
-                                    {
-                                        "$ref": "#/components/schemas/Item",
-                                        "examples": [
-                                            {
-                                                "name": "Foo",
-                                                "description": "A very nice Item",
-                                                "price": 35.4,
-                                                "tax": 3.2,
-                                            },
-                                            {"name": "Bar", "price": "35.4"},
-                                            {
-                                                "name": "Baz",
-                                                "price": "thirty five point four",
-                                            },
-                                        ],
-                                    }
-                                )
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {
-                                        "allOf": [
-                                            {"$ref": "#/components/schemas/Item"}
-                                        ],
-                                        "title": "Item",
-                                        "examples": [
-                                            {
-                                                "name": "Foo",
-                                                "description": "A very nice Item",
-                                                "price": 35.4,
-                                                "tax": 3.2,
-                                            },
-                                            {"name": "Bar", "price": "35.4"},
-                                            {
-                                                "name": "Baz",
-                                                "price": "thirty five point four",
-                                            },
-                                        ],
-                                    }
-                                )
+                                "schema": {
+                                    "$ref": "#/components/schemas/Item",
+                                    "examples": [
+                                        {
+                                            "name": "Foo",
+                                            "description": "A very nice Item",
+                                            "price": 35.4,
+                                            "tax": 3.2,
+                                        },
+                                        {"name": "Bar", "price": "35.4"},
+                                        {
+                                            "name": "Baz",
+                                            "price": "thirty five point four",
+                                        },
+                                    ],
+                                }
                             }
                         },
                         "required": True,
@@ -140,27 +115,15 @@ def test_openapi_schema(client: TestClient):
                     "type": "object",
                     "properties": {
                         "name": {"title": "Name", "type": "string"},
-                        "description": IsDict(
-                            {
-                                "title": "Description",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Description", "type": "string"}
-                        ),
+                        "description": {
+                            "title": "Description",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
+                        },
                         "price": {"title": "Price", "type": "number"},
-                        "tax": IsDict(
-                            {
-                                "title": "Tax",
-                                "anyOf": [{"type": "number"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Tax", "type": "number"}
-                        ),
+                        "tax": {
+                            "title": "Tax",
+                            "anyOf": [{"type": "number"}, {"type": "null"}],
+                        },
                     },
                 },
                 "ValidationError": {
index 1c964f3d15d7854c7115bc5e922f463fa796e689..2d0dee48ca55ea0b4c44d26b5bb5ff88f0920fb6 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
@@ -58,16 +57,7 @@ def test_openapi_schema(client: TestClient) -> None:
                     "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": IsDict({"$ref": "#/components/schemas/Item"})
-                                | IsDict(
-                                    # TODO: remove when deprecating Pydantic v1
-                                    {
-                                        "allOf": [
-                                            {"$ref": "#/components/schemas/Item"}
-                                        ],
-                                        "title": "Item",
-                                    }
-                                ),
+                                "schema": {"$ref": "#/components/schemas/Item"},
                                 "examples": {
                                     "normal": {
                                         "summary": "A normal example",
@@ -134,27 +124,15 @@ def test_openapi_schema(client: TestClient) -> None:
                     "type": "object",
                     "properties": {
                         "name": {"title": "Name", "type": "string"},
-                        "description": IsDict(
-                            {
-                                "title": "Description",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Description", "type": "string"}
-                        ),
+                        "description": {
+                            "title": "Description",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
+                        },
                         "price": {"title": "Price", "type": "number"},
-                        "tax": IsDict(
-                            {
-                                "title": "Tax",
-                                "anyOf": [{"type": "number"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Tax", "type": "number"}
-                        ),
+                        "tax": {
+                            "title": "Tax",
+                            "anyOf": [{"type": "number"}, {"type": "null"}],
+                        },
                     },
                 },
                 "ValidationError": {
index 000c8b2ac4a65068aad3de1540b51a875d0325fb..6a786348cff1130116ca7d0a2b2fdd72a8dac3b5 100644 (file)
@@ -1,7 +1,6 @@
 import importlib
 
 import pytest
-from dirty_equals import IsDict
 from fastapi.testclient import TestClient
 
 from ...utils import needs_py310
@@ -144,23 +143,13 @@ def test_openapi_schema(client: TestClient):
                     "required": ["username", "password"],
                     "type": "object",
                     "properties": {
-                        "grant_type": IsDict(
-                            {
-                                "title": "Grant Type",
-                                "anyOf": [
-                                    {"pattern": "^password$", "type": "string"},
-                                    {"type": "null"},
-                                ],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {
-                                "title": "Grant Type",
-                                "pattern": "^password$",
-                                "type": "string",
-                            }
-                        ),
+                        "grant_type": {
+                            "title": "Grant Type",
+                            "anyOf": [
+                                {"pattern": "^password$", "type": "string"},
+                                {"type": "null"},
+                            ],
+                        },
                         "username": {"title": "Username", "type": "string"},
                         "password": {
                             "title": "Password",
@@ -168,31 +157,15 @@ def test_openapi_schema(client: TestClient):
                             "format": "password",
                         },
                         "scope": {"title": "Scope", "type": "string", "default": ""},
-                        "client_id": IsDict(
-                            {
-                                "title": "Client Id",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Client Id", "type": "string"}
-                        ),
-                        "client_secret": IsDict(
-                            {
-                                "title": "Client Secret",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                                "format": "password",
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {
-                                "title": "Client Secret",
-                                "type": "string",
-                                "format": "password",
-                            }
-                        ),
+                        "client_id": {
+                            "title": "Client Id",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
+                        },
+                        "client_secret": {
+                            "title": "Client Secret",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
+                            "format": "password",
+                        },
                     },
                 },
                 "ValidationError": {
index 7953e8e3f6b892586ecdb789a9047a598c85d47d..25b47f0adc214edb94888f75e2bd67bc2755f0c1 100644 (file)
@@ -2,8 +2,8 @@ import importlib
 from types import ModuleType
 
 import pytest
-from dirty_equals import IsDict, IsOneOf
 from fastapi.testclient import TestClient
+from inline_snapshot import snapshot
 
 from ...utils import needs_py310
 
@@ -215,240 +215,200 @@ def test_openapi_schema(mod: ModuleType):
     client = TestClient(mod.app)
     response = client.get("/openapi.json")
     assert response.status_code == 200, response.text
-    assert response.json() == {
-        "openapi": "3.1.0",
-        "info": {"title": "FastAPI", "version": "0.1.0"},
-        "paths": {
-            "/token": {
-                "post": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {
-                                "application/json": {
-                                    "schema": {"$ref": "#/components/schemas/Token"}
-                                }
+    assert response.json() == snapshot(
+        {
+            "openapi": "3.1.0",
+            "info": {"title": "FastAPI", "version": "0.1.0"},
+            "paths": {
+                "/token": {
+                    "post": {
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {"$ref": "#/components/schemas/Token"}
+                                    }
+                                },
+                            },
+                            "422": {
+                                "description": "Validation Error",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {
+                                            "$ref": "#/components/schemas/HTTPValidationError"
+                                        }
+                                    }
+                                },
                             },
                         },
-                        "422": {
-                            "description": "Validation Error",
+                        "summary": "Login For Access Token",
+                        "operationId": "login_for_access_token_token_post",
+                        "requestBody": {
                             "content": {
-                                "application/json": {
+                                "application/x-www-form-urlencoded": {
                                     "schema": {
-                                        "$ref": "#/components/schemas/HTTPValidationError"
+                                        "$ref": "#/components/schemas/Body_login_for_access_token_token_post"
                                     }
                                 }
                             },
+                            "required": True,
                         },
-                    },
-                    "summary": "Login For Access Token",
-                    "operationId": "login_for_access_token_token_post",
-                    "requestBody": {
-                        "content": {
-                            "application/x-www-form-urlencoded": {
-                                "schema": {
-                                    "$ref": "#/components/schemas/Body_login_for_access_token_token_post"
-                                }
+                    }
+                },
+                "/users/me/": {
+                    "get": {
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {
+                                    "application/json": {
+                                        "schema": {"$ref": "#/components/schemas/User"}
+                                    }
+                                },
                             }
                         },
-                        "required": True,
-                    },
-                }
-            },
-            "/users/me/": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {
-                                "application/json": {
-                                    "schema": {"$ref": "#/components/schemas/User"}
-                                }
-                            },
-                        }
-                    },
-                    "summary": "Read Users Me",
-                    "operationId": "read_users_me_users_me__get",
-                    "security": [{"OAuth2PasswordBearer": ["me"]}],
-                }
-            },
-            "/users/me/items/": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        }
-                    },
-                    "summary": "Read Own Items",
-                    "operationId": "read_own_items_users_me_items__get",
-                    "security": [{"OAuth2PasswordBearer": ["items", "me"]}],
-                }
-            },
-            "/status/": {
-                "get": {
-                    "responses": {
-                        "200": {
-                            "description": "Successful Response",
-                            "content": {"application/json": {"schema": {}}},
-                        }
-                    },
-                    "summary": "Read System Status",
-                    "operationId": "read_system_status_status__get",
-                    "security": [{"OAuth2PasswordBearer": []}],
-                }
+                        "summary": "Read Users Me",
+                        "operationId": "read_users_me_users_me__get",
+                        "security": [{"OAuth2PasswordBearer": ["me"]}],
+                    }
+                },
+                "/users/me/items/": {
+                    "get": {
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {"application/json": {"schema": {}}},
+                            }
+                        },
+                        "summary": "Read Own Items",
+                        "operationId": "read_own_items_users_me_items__get",
+                        "security": [{"OAuth2PasswordBearer": ["items", "me"]}],
+                    }
+                },
+                "/status/": {
+                    "get": {
+                        "responses": {
+                            "200": {
+                                "description": "Successful Response",
+                                "content": {"application/json": {"schema": {}}},
+                            }
+                        },
+                        "summary": "Read System Status",
+                        "operationId": "read_system_status_status__get",
+                        "security": [{"OAuth2PasswordBearer": []}],
+                    }
+                },
             },
-        },
-        "components": {
-            "schemas": {
-                "User": {
-                    "title": "User",
-                    "required": IsOneOf(
-                        ["username", "email", "full_name", "disabled"],
-                        # TODO: remove when deprecating Pydantic v1
-                        ["username"],
-                    ),
-                    "type": "object",
-                    "properties": {
-                        "username": {"title": "Username", "type": "string"},
-                        "email": IsDict(
-                            {
+            "components": {
+                "schemas": {
+                    "User": {
+                        "title": "User",
+                        "required": ["username"],
+                        "type": "object",
+                        "properties": {
+                            "username": {"title": "Username", "type": "string"},
+                            "email": {
                                 "title": "Email",
                                 "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Email", "type": "string"}
-                        ),
-                        "full_name": IsDict(
-                            {
+                            },
+                            "full_name": {
                                 "title": "Full Name",
                                 "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Full Name", "type": "string"}
-                        ),
-                        "disabled": IsDict(
-                            {
+                            },
+                            "disabled": {
                                 "title": "Disabled",
                                 "anyOf": [{"type": "boolean"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Disabled", "type": "boolean"}
-                        ),
+                            },
+                        },
                     },
-                },
-                "Token": {
-                    "title": "Token",
-                    "required": ["access_token", "token_type"],
-                    "type": "object",
-                    "properties": {
-                        "access_token": {"title": "Access Token", "type": "string"},
-                        "token_type": {"title": "Token Type", "type": "string"},
+                    "Token": {
+                        "title": "Token",
+                        "required": ["access_token", "token_type"],
+                        "type": "object",
+                        "properties": {
+                            "access_token": {"title": "Access Token", "type": "string"},
+                            "token_type": {"title": "Token Type", "type": "string"},
+                        },
                     },
-                },
-                "Body_login_for_access_token_token_post": {
-                    "title": "Body_login_for_access_token_token_post",
-                    "required": ["username", "password"],
-                    "type": "object",
-                    "properties": {
-                        "grant_type": IsDict(
-                            {
+                    "Body_login_for_access_token_token_post": {
+                        "title": "Body_login_for_access_token_token_post",
+                        "required": ["username", "password"],
+                        "type": "object",
+                        "properties": {
+                            "grant_type": {
                                 "title": "Grant Type",
                                 "anyOf": [
                                     {"pattern": "^password$", "type": "string"},
                                     {"type": "null"},
                                 ],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {
-                                "title": "Grant Type",
-                                "pattern": "^password$",
+                            },
+                            "username": {"title": "Username", "type": "string"},
+                            "password": {
+                                "title": "Password",
                                 "type": "string",
-                            }
-                        ),
-                        "username": {"title": "Username", "type": "string"},
-                        "password": {
-                            "title": "Password",
-                            "type": "string",
-                            "format": "password",
-                        },
-                        "scope": {"title": "Scope", "type": "string", "default": ""},
-                        "client_id": IsDict(
-                            {
+                                "format": "password",
+                            },
+                            "scope": {
+                                "title": "Scope",
+                                "type": "string",
+                                "default": "",
+                            },
+                            "client_id": {
                                 "title": "Client Id",
                                 "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Client Id", "type": "string"}
-                        ),
-                        "client_secret": IsDict(
-                            {
+                            },
+                            "client_secret": {
                                 "title": "Client Secret",
                                 "anyOf": [{"type": "string"}, {"type": "null"}],
                                 "format": "password",
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {
-                                "title": "Client Secret",
-                                "type": "string",
-                                "format": "password",
-                            }
-                        ),
+                            },
+                        },
                     },
-                },
-                "ValidationError": {
-                    "title": "ValidationError",
-                    "required": ["loc", "msg", "type"],
-                    "type": "object",
-                    "properties": {
-                        "loc": {
-                            "title": "Location",
-                            "type": "array",
-                            "items": {
-                                "anyOf": [{"type": "string"}, {"type": "integer"}]
+                    "ValidationError": {
+                        "title": "ValidationError",
+                        "required": ["loc", "msg", "type"],
+                        "type": "object",
+                        "properties": {
+                            "loc": {
+                                "title": "Location",
+                                "type": "array",
+                                "items": {
+                                    "anyOf": [{"type": "string"}, {"type": "integer"}]
+                                },
                             },
+                            "msg": {"title": "Message", "type": "string"},
+                            "type": {"title": "Error Type", "type": "string"},
                         },
-                        "msg": {"title": "Message", "type": "string"},
-                        "type": {"title": "Error Type", "type": "string"},
                     },
-                },
-                "HTTPValidationError": {
-                    "title": "HTTPValidationError",
-                    "type": "object",
-                    "properties": {
-                        "detail": {
-                            "title": "Detail",
-                            "type": "array",
-                            "items": {"$ref": "#/components/schemas/ValidationError"},
-                        }
+                    "HTTPValidationError": {
+                        "title": "HTTPValidationError",
+                        "type": "object",
+                        "properties": {
+                            "detail": {
+                                "title": "Detail",
+                                "type": "array",
+                                "items": {
+                                    "$ref": "#/components/schemas/ValidationError"
+                                },
+                            }
+                        },
                     },
                 },
+                "securitySchemes": {
+                    "OAuth2PasswordBearer": {
+                        "type": "oauth2",
+                        "flows": {
+                            "password": {
+                                "scopes": {
+                                    "me": "Read information about the current user.",
+                                    "items": "Read items.",
+                                },
+                                "tokenUrl": "token",
+                            }
+                        },
+                    }
+                },
             },
-            "securitySchemes": {
-                "OAuth2PasswordBearer": {
-                    "type": "oauth2",
-                    "flows": {
-                        "password": {
-                            "scopes": {
-                                "me": "Read information about the current user.",
-                                "items": "Read items.",
-                            },
-                            "tokenUrl": "token",
-                        }
-                    },
-                }
-            },
-        },
-    }
+        }
+    )
index e3e6bac12842ba0d00068b4c95b7b45756e0e1b6..2c628f52571572ca0d8715c2206fb4b8f2c7d3f5 100644 (file)
@@ -2,7 +2,7 @@ import importlib
 import warnings
 
 import pytest
-from dirty_equals import IsDict, IsInt
+from dirty_equals import IsInt
 from fastapi.testclient import TestClient
 from inline_snapshot import snapshot
 from sqlalchemy import StaticPool
@@ -318,33 +318,15 @@ def test_openapi_schema(client: TestClient):
                     },
                     "Hero": {
                         "properties": {
-                            "id": IsDict(
-                                {
-                                    "anyOf": [{"type": "integer"}, {"type": "null"}],
-                                    "title": "Id",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {
-                                    "type": "integer",
-                                    "title": "Id",
-                                }
-                            ),
+                            "id": {
+                                "anyOf": [{"type": "integer"}, {"type": "null"}],
+                                "title": "Id",
+                            },
                             "name": {"type": "string", "title": "Name"},
-                            "age": IsDict(
-                                {
-                                    "anyOf": [{"type": "integer"}, {"type": "null"}],
-                                    "title": "Age",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {
-                                    "type": "integer",
-                                    "title": "Age",
-                                }
-                            ),
+                            "age": {
+                                "anyOf": [{"type": "integer"}, {"type": "null"}],
+                                "title": "Age",
+                            },
                             "secret_name": {"type": "string", "title": "Secret Name"},
                         },
                         "type": "object",
index e3b8c7f9e43f506fb123dc613b6f23232c040422..c72c16e9ae663d3086fd727c52ab923ddbc7c533 100644 (file)
@@ -2,7 +2,7 @@ import importlib
 import warnings
 
 import pytest
-from dirty_equals import IsDict, IsInt
+from dirty_equals import IsInt
 from fastapi.testclient import TestClient
 from inline_snapshot import Is, snapshot
 from sqlalchemy import StaticPool
@@ -373,19 +373,10 @@ def test_openapi_schema(client: TestClient):
                     "HeroCreate": {
                         "properties": {
                             "name": {"type": "string", "title": "Name"},
-                            "age": IsDict(
-                                {
-                                    "anyOf": [{"type": "integer"}, {"type": "null"}],
-                                    "title": "Age",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {
-                                    "type": "integer",
-                                    "title": "Age",
-                                }
-                            ),
+                            "age": {
+                                "anyOf": [{"type": "integer"}, {"type": "null"}],
+                                "title": "Age",
+                            },
                             "secret_name": {"type": "string", "title": "Secret Name"},
                         },
                         "type": "object",
@@ -395,19 +386,10 @@ def test_openapi_schema(client: TestClient):
                     "HeroPublic": {
                         "properties": {
                             "name": {"type": "string", "title": "Name"},
-                            "age": IsDict(
-                                {
-                                    "anyOf": [{"type": "integer"}, {"type": "null"}],
-                                    "title": "Age",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {
-                                    "type": "integer",
-                                    "title": "Age",
-                                }
-                            ),
+                            "age": {
+                                "anyOf": [{"type": "integer"}, {"type": "null"}],
+                                "title": "Age",
+                            },
                             "id": {"type": "integer", "title": "Id"},
                         },
                         "type": "object",
@@ -416,45 +398,18 @@ def test_openapi_schema(client: TestClient):
                     },
                     "HeroUpdate": {
                         "properties": {
-                            "name": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Name",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {
-                                    "type": "string",
-                                    "title": "Name",
-                                }
-                            ),
-                            "age": IsDict(
-                                {
-                                    "anyOf": [{"type": "integer"}, {"type": "null"}],
-                                    "title": "Age",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {
-                                    "type": "integer",
-                                    "title": "Age",
-                                }
-                            ),
-                            "secret_name": IsDict(
-                                {
-                                    "anyOf": [{"type": "string"}, {"type": "null"}],
-                                    "title": "Secret Name",
-                                }
-                            )
-                            | IsDict(
-                                # TODO: remove when deprecating Pydantic v1
-                                {
-                                    "type": "string",
-                                    "title": "Secret Name",
-                                }
-                            ),
+                            "name": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "Name",
+                            },
+                            "age": {
+                                "anyOf": [{"type": "integer"}, {"type": "null"}],
+                                "title": "Age",
+                            },
+                            "secret_name": {
+                                "anyOf": [{"type": "string"}, {"type": "null"}],
+                                "title": "Secret Name",
+                            },
                         },
                         "type": "object",
                         "title": "HeroUpdate",
index c15acacd18d3d5f74903766f1459c098f169e9f3..ee7fcc42316e3e2770d4093108f2ff96466bcab5 100644 (file)
@@ -1,6 +1,5 @@
 from typing import Optional, Union
 
-from dirty_equals import IsDict
 from fastapi import FastAPI
 from fastapi.testclient import TestClient
 from pydantic import BaseModel
@@ -91,18 +90,12 @@ def test_openapi_schema():
                 "Item": {
                     "title": "Item",
                     "type": "object",
-                    "properties": IsDict(
-                        {
-                            "name": {
-                                "title": "Name",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
+                    "properties": {
+                        "name": {
+                            "title": "Name",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
                         }
-                    )
-                    | IsDict(
-                        # TODO: remove when deprecating Pydantic v1
-                        {"name": {"title": "Name", "type": "string"}}
-                    ),
+                    },
                 },
                 "ValidationError": {
                     "title": "ValidationError",
index 40fd0065a95fe67f82a234db455e8f8fb5e353de..6c31649bcc5154ec0a31c6e5f4c5ca46ab35d0ee 100644 (file)
@@ -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",
+                                        }
                                     }
                                 },
                             },
index ef75d459ead1f71d571e835ad1b4ec612555299d..3c062e7f5a7ba7a13272a3ca7a298e0e3f8a251e 100644 (file)
@@ -1,6 +1,5 @@
 from typing import Optional, Union
 
-from dirty_equals import IsDict
 from fastapi import FastAPI
 from fastapi.testclient import TestClient
 from pydantic import BaseModel
@@ -86,16 +85,10 @@ def test_openapi_schema():
                     "title": "Item",
                     "type": "object",
                     "properties": {
-                        "name": IsDict(
-                            {
-                                "title": "Name",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Name", "type": "string"}
-                        )
+                        "name": {
+                            "title": "Name",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
+                        }
                     },
                 },
                 "ExtendedItem": {
@@ -103,16 +96,10 @@ def test_openapi_schema():
                     "required": ["age"],
                     "type": "object",
                     "properties": {
-                        "name": IsDict(
-                            {
-                                "title": "Name",
-                                "anyOf": [{"type": "string"}, {"type": "null"}],
-                            }
-                        )
-                        | IsDict(
-                            # TODO: remove when deprecating Pydantic v1
-                            {"title": "Name", "type": "string"}
-                        ),
+                        "name": {
+                            "title": "Name",
+                            "anyOf": [{"type": "string"}, {"type": "null"}],
+                        },
                         "age": {"title": "Age", "type": "integer"},
                     },
                 },