Skip to content

Commit

Permalink
fix: adapt tests to new pydantic versions
Browse files Browse the repository at this point in the history
  • Loading branch information
percevalw committed Sep 2, 2024
1 parent 48fd0e0 commit e2bb631
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,29 +195,29 @@ def __init__(self, model: Model):
with pytest.raises(ConfitValidationError) as e:
Model(raise_attribute=False)
if PYDANTIC_V1:
assert str(e.value) == (
"1 validation error for test_validate.test_fail_init.<locals>.SubModel()\n"
assert str(e.value).replace("test_validate.test_fail_init.<locals>.", "") == (
"1 validation error for SubModel()\n"
"-> raise_attribute\n"
" field required"
)
else:
assert str(e.value) == (
"1 validation error for test_validate.test_fail_init.<locals>.SubModel()\n"
assert str(e.value).replace("test_validate.test_fail_init.<locals>.", "") == (
"1 validation error for SubModel()\n"
"-> raise_attribute\n"
" field required"
)

with pytest.raises(ConfitValidationError) as e:
BigModel(model=dict(raise_attribute="ok"))
if PYDANTIC_V1:
assert str(e.value) == (
"1 validation error for test_validate.test_fail_init.<locals>.BigModel()\n"
assert str(e.value).replace("test_validate.test_fail_init.<locals>.", "") == (
"1 validation error for BigModel()\n"
"-> model.raise_attribute\n"
" value is not a valid boolean, got 'ok' (str)"
)
else:
assert str(e.value) == (
"1 validation error for test_validate.test_fail_init.<locals>.BigModel()\n"
assert str(e.value).replace("test_validate.test_fail_init.<locals>.", "") == (
"1 validation error for BigModel()\n"
"-> model.raise_attribute\n"
" input should be a valid boolean, got 'ok' (str)"
)
Expand All @@ -226,10 +226,10 @@ def __init__(self, model: Model):
with pytest.raises(ConfitValidationError) as e:
BigModel(model=dict(raise_attribute=False))
# Nested error because we cannot merge the submodel error into the model error
assert str(e.value) == (
"1 validation error for test_validate.test_fail_init.<locals>.BigModel()\n"
assert str(e.value).replace("test_validate.test_fail_init.<locals>.", "") == (
"1 validation error for BigModel()\n"
"-> model\n"
" 1 validation error for test_validate.test_fail_init.<locals>.SubModel()\n"
" 1 validation error for SubModel()\n"
" -> raise_attribute\n"
" field required"
)
Expand Down

0 comments on commit e2bb631

Please sign in to comment.