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

[PATCH] EB-124910 Adding pointer to extra key error dictionary field #79

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conformity/fields/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ def errors(self, value): # type: (AnyType) -> ListType[Error]
Error(
'Extra keys present: {}'.format(', '.join(six.text_type(key) for key in sorted(extra_keys))),
code=ERROR_CODE_UNKNOWN,
pointer=six.text_type(sorted(extra_keys)[0]),
),
)

Expand Down
6 changes: 5 additions & 1 deletion tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ def test_complex(self): # type: () -> None
sorted([
Error('Not an integer', pointer='child_ids.2'),
Error('Missing key: address', code=ERROR_CODE_MISSING, pointer='address'),
Error('Extra keys present: another_bad, unsolicited_item', code=ERROR_CODE_UNKNOWN),
Error(
lautaro-eb marked this conversation as resolved.
Show resolved Hide resolved
'Extra keys present: another_bad, unsolicited_item',
code=ERROR_CODE_UNKNOWN,
pointer='another_bad',
),
Error('Not a set or frozenset', pointer='unique_things'),
]),
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def test_validation(self):
},
})

assert '- inner_qux: Extra keys present: not_defined' in error_context.value.args[0]
assert '- inner_qux.not_defined: Extra keys present: not_defined' in error_context.value.args[0]

with pytest.raises(Settings.ImproperlyConfigured) as error_context:
SettingsTwo({
Expand Down