Skip to content

Commit

Permalink
revise test
Browse files Browse the repository at this point in the history
  • Loading branch information
changhc committed Nov 21, 2024
1 parent 4a8aa3e commit 8e85a60
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/validators/test_model_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,12 @@ def test_deprecation_msg():
'b': {
'type': 'model-field',
'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 2},
'deprecation_msg': 'hi',
'deprecation_msg': 'foo',
},
'c': {
'type': 'model-field',
'schema': {'type': 'default', 'schema': {'type': 'int'}, 'default': 2},
'deprecation_msg': 'bar',
},
},
}
Expand All @@ -1802,5 +1807,9 @@ def test_deprecation_msg():
v.validate_python({'a': 1})

# validating the deprecated field: raise warning
with pytest.warns(DeprecationWarning, match='hi'):
v.validate_python({'a': 1, 'b': 1})
# ensure that we get two warnings
with pytest.warns(DeprecationWarning) as w:
v.validate_python({'a': 1, 'b': 1, 'c': 1})
assert len(w) == 2
assert str(w[0].message) == 'foo'
assert str(w[1].message) == 'bar'

0 comments on commit 8e85a60

Please sign in to comment.