]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
♻️ Refactor tests for new Pydantic 2.2.1 (#10115)
authorSebastián Ramírez <tiangolo@gmail.com>
Sat, 19 Aug 2023 18:47:59 +0000 (20:47 +0200)
committerGitHub <noreply@github.com>
Sat, 19 Aug 2023 18:47:59 +0000 (20:47 +0200)
.github/workflows/test.yml
tests/test_multi_body_errors.py
tests/test_tutorial/test_body_updates/test_tutorial001.py
tests/test_tutorial/test_body_updates/test_tutorial001_py310.py
tests/test_tutorial/test_body_updates/test_tutorial001_py39.py
tests/test_tutorial/test_dataclasses/test_tutorial003.py
tests/test_tutorial/test_path_operation_advanced_configurations/test_tutorial004.py
tests/test_tutorial/test_path_operation_configurations/test_tutorial005.py
tests/test_tutorial/test_path_operation_configurations/test_tutorial005_py310.py
tests/test_tutorial/test_path_operation_configurations/test_tutorial005_py39.py

index 6a512a019b8a5639f3aac6f062fd0986d5122223..c9723b25bbace98862f25552edc13fcd5a220cb8 100644 (file)
@@ -29,7 +29,7 @@ jobs:
         id: cache
         with:
           path: ${{ env.pythonLocation }}
-          key: ${{ runner.os }}-python-${{ env.pythonLocation }}-pydantic-v2-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-test-v04
+          key: ${{ runner.os }}-python-${{ env.pythonLocation }}-pydantic-v2-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-test-v05
       - name: Install Dependencies
         if: steps.cache.outputs.cache-hit != 'true'
         run: pip install -r requirements-tests.txt
@@ -62,7 +62,7 @@ jobs:
         id: cache
         with:
           path: ${{ env.pythonLocation }}
-          key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ matrix.pydantic-version }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-test-v04
+          key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ matrix.pydantic-version }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-test-v05
       - name: Install Dependencies
         if: steps.cache.outputs.cache-hit != 'true'
         run: pip install -r requirements-tests.txt
index 931f08fc1cf5c6725239d7bd393fecd8556da391..a51ca7253f8257c7b522013b8995766002d3b331 100644 (file)
@@ -51,7 +51,7 @@ def test_jsonable_encoder_requiring_error():
                     "loc": ["body", 0, "age"],
                     "msg": "Input should be greater than 0",
                     "input": -1.0,
-                    "ctx": {"gt": "0"},
+                    "ctx": {"gt": 0},
                     "url": match_pydantic_error_url("greater_than"),
                 }
             ]
@@ -84,25 +84,12 @@ def test_put_incorrect_body_multiple():
                     "input": {"age": "five"},
                     "url": match_pydantic_error_url("missing"),
                 },
-                {
-                    "ctx": {"class": "Decimal"},
-                    "input": "five",
-                    "loc": ["body", 0, "age", "is-instance[Decimal]"],
-                    "msg": "Input should be an instance of Decimal",
-                    "type": "is_instance_of",
-                    "url": match_pydantic_error_url("is_instance_of"),
-                },
                 {
                     "type": "decimal_parsing",
-                    "loc": [
-                        "body",
-                        0,
-                        "age",
-                        "function-after[to_decimal(), "
-                        "union[int,constrained-str,function-plain[str()]]]",
-                    ],
+                    "loc": ["body", 0, "age"],
                     "msg": "Input should be a valid decimal",
                     "input": "five",
+                    "url": match_pydantic_error_url("decimal_parsing"),
                 },
                 {
                     "type": "missing",
@@ -111,25 +98,12 @@ def test_put_incorrect_body_multiple():
                     "input": {"age": "six"},
                     "url": match_pydantic_error_url("missing"),
                 },
-                {
-                    "ctx": {"class": "Decimal"},
-                    "input": "six",
-                    "loc": ["body", 1, "age", "is-instance[Decimal]"],
-                    "msg": "Input should be an instance of Decimal",
-                    "type": "is_instance_of",
-                    "url": match_pydantic_error_url("is_instance_of"),
-                },
                 {
                     "type": "decimal_parsing",
-                    "loc": [
-                        "body",
-                        1,
-                        "age",
-                        "function-after[to_decimal(), "
-                        "union[int,constrained-str,function-plain[str()]]]",
-                    ],
+                    "loc": ["body", 1, "age"],
                     "msg": "Input should be a valid decimal",
                     "input": "six",
+                    "url": match_pydantic_error_url("decimal_parsing"),
                 },
             ]
         }
index f1a46210aadeab9f3bb3d2864d3859ebe3d2ff71..58587885efdb07748ecb0c30a324c73c0ab1eee1 100644 (file)
@@ -53,7 +53,7 @@ def test_openapi_schema(client: TestClient):
                             "content": {
                                 "application/json": {
                                     "schema": {
-                                        "$ref": "#/components/schemas/ItemOutput"
+                                        "$ref": "#/components/schemas/Item-Output"
                                     }
                                 }
                             },
@@ -87,7 +87,7 @@ def test_openapi_schema(client: TestClient):
                             "content": {
                                 "application/json": {
                                     "schema": {
-                                        "$ref": "#/components/schemas/ItemOutput"
+                                        "$ref": "#/components/schemas/Item-Output"
                                     }
                                 }
                             },
@@ -116,7 +116,7 @@ def test_openapi_schema(client: TestClient):
                     "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {"$ref": "#/components/schemas/ItemInput"}
+                                "schema": {"$ref": "#/components/schemas/Item-Input"}
                             }
                         },
                         "required": True,
@@ -126,7 +126,7 @@ def test_openapi_schema(client: TestClient):
         },
         "components": {
             "schemas": {
-                "ItemInput": {
+                "Item-Input": {
                     "title": "Item",
                     "type": "object",
                     "properties": {
@@ -151,7 +151,7 @@ def test_openapi_schema(client: TestClient):
                         },
                     },
                 },
-                "ItemOutput": {
+                "Item-Output": {
                     "title": "Item",
                     "type": "object",
                     "required": ["name", "description", "price", "tax", "tags"],
index ab696e4c8dfec5704b3d062402c3ccc067c0674a..d8a62502f0a843cdf200fe85306c2c31c8d10e06 100644 (file)
@@ -56,7 +56,7 @@ def test_openapi_schema(client: TestClient):
                             "content": {
                                 "application/json": {
                                     "schema": {
-                                        "$ref": "#/components/schemas/ItemOutput"
+                                        "$ref": "#/components/schemas/Item-Output"
                                     }
                                 }
                             },
@@ -90,7 +90,7 @@ def test_openapi_schema(client: TestClient):
                             "content": {
                                 "application/json": {
                                     "schema": {
-                                        "$ref": "#/components/schemas/ItemOutput"
+                                        "$ref": "#/components/schemas/Item-Output"
                                     }
                                 }
                             },
@@ -119,7 +119,7 @@ def test_openapi_schema(client: TestClient):
                     "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {"$ref": "#/components/schemas/ItemInput"}
+                                "schema": {"$ref": "#/components/schemas/Item-Input"}
                             }
                         },
                         "required": True,
@@ -129,7 +129,7 @@ def test_openapi_schema(client: TestClient):
         },
         "components": {
             "schemas": {
-                "ItemInput": {
+                "Item-Input": {
                     "title": "Item",
                     "type": "object",
                     "properties": {
@@ -154,7 +154,7 @@ def test_openapi_schema(client: TestClient):
                         },
                     },
                 },
-                "ItemOutput": {
+                "Item-Output": {
                     "title": "Item",
                     "type": "object",
                     "required": ["name", "description", "price", "tax", "tags"],
index 2ee6a5cb4c695639ee8c564f684d49bdfc116900..c604df6ecb7e9223b4d5479048a07b3af312bf5a 100644 (file)
@@ -56,7 +56,7 @@ def test_openapi_schema(client: TestClient):
                             "content": {
                                 "application/json": {
                                     "schema": {
-                                        "$ref": "#/components/schemas/ItemOutput"
+                                        "$ref": "#/components/schemas/Item-Output"
                                     }
                                 }
                             },
@@ -90,7 +90,7 @@ def test_openapi_schema(client: TestClient):
                             "content": {
                                 "application/json": {
                                     "schema": {
-                                        "$ref": "#/components/schemas/ItemOutput"
+                                        "$ref": "#/components/schemas/Item-Output"
                                     }
                                 }
                             },
@@ -119,7 +119,7 @@ def test_openapi_schema(client: TestClient):
                     "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {"$ref": "#/components/schemas/ItemInput"}
+                                "schema": {"$ref": "#/components/schemas/Item-Input"}
                             }
                         },
                         "required": True,
@@ -129,7 +129,7 @@ def test_openapi_schema(client: TestClient):
         },
         "components": {
             "schemas": {
-                "ItemInput": {
+                "Item-Input": {
                     "title": "Item",
                     "type": "object",
                     "properties": {
@@ -154,7 +154,7 @@ def test_openapi_schema(client: TestClient):
                         },
                     },
                 },
-                "ItemOutput": {
+                "Item-Output": {
                     "title": "Item",
                     "type": "object",
                     "required": ["name", "description", "price", "tax", "tags"],
index 2e5809914f8500a00fca0a703ace1b36731f165d..f2ca858235faf1d37ae02cc0571e6a2b6e38abb1 100644 (file)
@@ -79,7 +79,9 @@ def test_openapi_schema():
                                 "schema": {
                                     "title": "Items",
                                     "type": "array",
-                                    "items": {"$ref": "#/components/schemas/ItemInput"},
+                                    "items": {
+                                        "$ref": "#/components/schemas/Item-Input"
+                                    },
                                 }
                             }
                         },
@@ -141,7 +143,7 @@ def test_openapi_schema():
                         "items": {
                             "title": "Items",
                             "type": "array",
-                            "items": {"$ref": "#/components/schemas/ItemOutput"},
+                            "items": {"$ref": "#/components/schemas/Item-Output"},
                         },
                     },
                 },
@@ -156,7 +158,7 @@ def test_openapi_schema():
                         }
                     },
                 },
-                "ItemInput": {
+                "Item-Input": {
                     "title": "Item",
                     "required": ["name"],
                     "type": "object",
@@ -168,7 +170,7 @@ def test_openapi_schema():
                         },
                     },
                 },
-                "ItemOutput": {
+                "Item-Output": {
                     "title": "Item",
                     "required": ["name", "description"],
                     "type": "object",
index 3ffc0bca7ce628fe4d885ddc8a7a4aee0d44ed1a..c5b2fb670b21305c417d0794ed9f465073918aa3 100644 (file)
@@ -35,7 +35,7 @@ def test_openapi_schema():
                             "content": {
                                 "application/json": {
                                     "schema": {
-                                        "$ref": "#/components/schemas/ItemOutput"
+                                        "$ref": "#/components/schemas/Item-Output"
                                     }
                                 }
                             },
@@ -57,7 +57,7 @@ def test_openapi_schema():
                     "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {"$ref": "#/components/schemas/ItemInput"}
+                                "schema": {"$ref": "#/components/schemas/Item-Input"}
                             }
                         },
                         "required": True,
@@ -67,7 +67,7 @@ def test_openapi_schema():
         },
         "components": {
             "schemas": {
-                "ItemInput": {
+                "Item-Input": {
                     "title": "Item",
                     "required": ["name", "price"],
                     "type": "object",
@@ -91,7 +91,7 @@ def test_openapi_schema():
                         },
                     },
                 },
-                "ItemOutput": {
+                "Item-Output": {
                     "title": "Item",
                     "required": ["name", "description", "price", "tax", "tags"],
                     "type": "object",
index ff98295a60a44b6763627ffe7fd8db26e0222807..458923b5a08f87ee8f4c2ccb17636fb88c798850 100644 (file)
@@ -35,7 +35,7 @@ def test_openapi_schema():
                             "content": {
                                 "application/json": {
                                     "schema": {
-                                        "$ref": "#/components/schemas/ItemOutput"
+                                        "$ref": "#/components/schemas/Item-Output"
                                     }
                                 }
                             },
@@ -57,7 +57,7 @@ def test_openapi_schema():
                     "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {"$ref": "#/components/schemas/ItemInput"}
+                                "schema": {"$ref": "#/components/schemas/Item-Input"}
                             }
                         },
                         "required": True,
@@ -67,7 +67,7 @@ def test_openapi_schema():
         },
         "components": {
             "schemas": {
-                "ItemInput": {
+                "Item-Input": {
                     "title": "Item",
                     "required": ["name", "price"],
                     "type": "object",
@@ -91,7 +91,7 @@ def test_openapi_schema():
                         },
                     },
                 },
-                "ItemOutput": {
+                "Item-Output": {
                     "title": "Item",
                     "required": ["name", "description", "price", "tax", "tags"],
                     "type": "object",
index ad1c09eaec5087df85aa7b32163103a1359bead1..1fcc5c4e0cba0630a65a3ba4a63c80200e5dbf0f 100644 (file)
@@ -42,7 +42,7 @@ def test_openapi_schema(client: TestClient):
                             "content": {
                                 "application/json": {
                                     "schema": {
-                                        "$ref": "#/components/schemas/ItemOutput"
+                                        "$ref": "#/components/schemas/Item-Output"
                                     }
                                 }
                             },
@@ -64,7 +64,7 @@ def test_openapi_schema(client: TestClient):
                     "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {"$ref": "#/components/schemas/ItemInput"}
+                                "schema": {"$ref": "#/components/schemas/Item-Input"}
                             }
                         },
                         "required": True,
@@ -74,7 +74,7 @@ def test_openapi_schema(client: TestClient):
         },
         "components": {
             "schemas": {
-                "ItemInput": {
+                "Item-Input": {
                     "title": "Item",
                     "required": ["name", "price"],
                     "type": "object",
@@ -98,7 +98,7 @@ def test_openapi_schema(client: TestClient):
                         },
                     },
                 },
-                "ItemOutput": {
+                "Item-Output": {
                     "title": "Item",
                     "required": ["name", "description", "price", "tax", "tags"],
                     "type": "object",
index 045d1d402c949facab6e7973ce5baf1b61c74cdc..470fe032b162458f746289067a92ad6a367e3b61 100644 (file)
@@ -42,7 +42,7 @@ def test_openapi_schema(client: TestClient):
                             "content": {
                                 "application/json": {
                                     "schema": {
-                                        "$ref": "#/components/schemas/ItemOutput"
+                                        "$ref": "#/components/schemas/Item-Output"
                                     }
                                 }
                             },
@@ -64,7 +64,7 @@ def test_openapi_schema(client: TestClient):
                     "requestBody": {
                         "content": {
                             "application/json": {
-                                "schema": {"$ref": "#/components/schemas/ItemInput"}
+                                "schema": {"$ref": "#/components/schemas/Item-Input"}
                             }
                         },
                         "required": True,
@@ -74,7 +74,7 @@ def test_openapi_schema(client: TestClient):
         },
         "components": {
             "schemas": {
-                "ItemInput": {
+                "Item-Input": {
                     "title": "Item",
                     "required": ["name", "price"],
                     "type": "object",
@@ -98,7 +98,7 @@ def test_openapi_schema(client: TestClient):
                         },
                     },
                 },
-                "ItemOutput": {
+                "Item-Output": {
                     "title": "Item",
                     "required": ["name", "description", "price", "tax", "tags"],
                     "type": "object",