Skip to content

Commit

Permalink
Fix plurals in validation error messages (in tests) (#7972)
Browse files Browse the repository at this point in the history
  • Loading branch information
Iipin committed Nov 3, 2023
1 parent fb185a7 commit 0a2377e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
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

0 comments on commit 0a2377e

Please sign in to comment.