Repository navigation
test: assert Field.make_error kwargs interpolation and Tuple partial valid_data - #3105
Draft
janmejai2002 wants to merge 1 commit into
Draft
janmejai2002 wants to merge 1 commit into
janmejai2002 wants to merge 1 commit into
Conversation
Member
|
Not sure the latter is intended (#201340). |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds unit test coverage for two subtle behavioral contracts in
marshmallow.fields:Field.make_error(**kwargs)formatting interpolation:Field.make_erroris designed to format error message templates with keyword arguments viamsg.format(**kwargs).tests/test_fields.pyonly exercisedfield.make_error(key)with static strings and without kwargs, leaving template parameter substitution unasserted.test_make_error_with_formatting_kwargsto verify that passing keyword arguments (e.g.field.make_error("formatted", field_name="age", min_val=18)) properly interpolates placeholders into the resultingValidationErrormessage.Tuplepartialvalid_dataretention on deserialization failure:Tuplefield encounters deserialization failures in one or more elements, it collects validly parsed elements intoValidationError.valid_data(raise ValidationError(errors, valid_data=result)).tests/test_deserialization.pyverified the error dictionary (exc.messages), but did not assertexc.valid_data.exc.valid_data == ["good"].exc.valid_data == ["good"]without inserting prematureNoneentries.Verification
pytest tests/test_fields.py tests/test_deserialization.py -q: 507 passed in 0.85s (0 failures).ruff checkandruff format --check: all checks passed, 0 errors.fields.Tuple,fields.Integer,fields.Str, and realValidationErrorinstances.