id: cache
with:
path: ${{ env.pythonLocation }}
- key: ${{ runner.os }}-python-${{ env.pythonLocation }}-pydantic-v2-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-test-v03
+ key: ${{ runner.os }}-python-${{ env.pythonLocation }}-pydantic-v2-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-test-v04
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements-tests.txt
id: cache
with:
path: ${{ env.pythonLocation }}
- key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ matrix.pydantic-version }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-test-v03
+ key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ matrix.pydantic-version }}-${{ hashFiles('pyproject.toml', 'requirements-tests.txt') }}-test-v04
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install -r requirements-tests.txt
from typing import Optional
import pytest
-from dirty_equals import IsDict
+from dirty_equals import HasRepr, IsDict
from fastapi import Depends, FastAPI
from fastapi.exceptions import ResponseValidationError
from fastapi.testclient import TestClient
"loc": ("response", "name"),
"msg": "Value error, name must end in A",
"input": "modelX",
- "ctx": {"error": "name must end in A"},
+ "ctx": {"error": HasRepr("ValueError('name must end in A')")},
"url": match_pydantic_error_url("value_error"),
}
)
"loc": ["body", 0, "age"],
"msg": "Input should be greater than 0",
"input": -1.0,
- "ctx": {"gt": 0.0},
+ "ctx": {"gt": "0"},
"url": match_pydantic_error_url("greater_than"),
}
]
"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"],
+ "loc": [
+ "body",
+ 0,
+ "age",
+ "function-after[to_decimal(), "
+ "union[int,constrained-str,function-plain[str()]]]",
+ ],
"msg": "Input should be a valid decimal",
"input": "five",
},
"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"],
+ "loc": [
+ "body",
+ 1,
+ "age",
+ "function-after[to_decimal(), "
+ "union[int,constrained-str,function-plain[str()]]]",
+ ],
"msg": "Input should be a valid decimal",
"input": "six",
},