Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix plurals in validation error messages (in tests) #7972

Merged
merged 2 commits into from Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions tests/test_main.py
Expand Up @@ -673,6 +673,7 @@ def test_validating_assignment_pass(ValidateAssignmentModel):
assert p.model_dump() == {'a': 2, 'b': 'hi'}


@pytest.mark.xfail(reason='Needs new release of pydantic-core')
def test_validating_assignment_fail(ValidateAssignmentModel):
p = ValidateAssignmentModel(a=5, b='hello')

Expand All @@ -693,7 +694,7 @@ def test_validating_assignment_fail(ValidateAssignmentModel):
{
'type': 'string_too_short',
'loc': ('b',),
'msg': 'String should have at least 1 characters',
'msg': 'String should have at least 1 character',
'input': '',
'ctx': {'min_length': 1},
}
Expand Down Expand Up @@ -3030,6 +3031,7 @@ class Model(BaseModel):
]


@pytest.mark.xfail(reason='Needs new release of pydantic-core')
def test_schema_generator_customize_type_constraints_order() -> None:
class Model(BaseModel):
# whitespace will be stripped first, then max length will be checked, should pass on ' 1 '
Expand All @@ -3045,7 +3047,7 @@ class Model(BaseModel):
{
'type': 'string_too_long',
'loc': ('y',),
'msg': 'String should have at most 1 characters',
'msg': 'String should have at most 1 character',
'input': ' 1 ',
'ctx': {'max_length': 1},
}
Expand Down
5 changes: 3 additions & 2 deletions tests/test_types.py
Expand Up @@ -3057,20 +3057,21 @@ class Model(BaseModel):
],
),
(dict(max_digits=2, decimal_places=2), Decimal('0.99'), Decimal('0.99')),
(
pytest.param(
dict(max_digits=2, decimal_places=1),
Decimal('0.99'),
[
{
'type': 'decimal_max_places',
'loc': ('foo',),
'msg': 'Decimal input should have no more than 1 decimal places',
'msg': 'Decimal input should have no more than 1 decimal place',
'input': Decimal('0.99'),
'ctx': {
'decimal_places': 1,
},
}
],
marks=pytest.mark.xfail(reason='Needs new release of pydantic-core'),
),
(
dict(max_digits=3, decimal_places=1),
Expand Down