-
-
Notifications
You must be signed in to change notification settings - Fork 601
Fix error paths when additionalItems is used with items keyword #123
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -500,6 +500,23 @@ def test_additionalItems(self): | |
| self.assertEqual(e1.validator, "type") | ||
| self.assertEqual(e2.validator, "minimum") | ||
|
|
||
| def test_additionalItems_with_items(self): | ||
| instance = ["foo", "bar", 1] | ||
| schema = { | ||
| "items": [{}], | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was correct as-is, wasn't it, it just covered a case with empty items? If so we should leave the old test case and just add this as a new one.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, will do. |
||
| "additionalItems" : {"type": "integer", "minimum": 5} | ||
| } | ||
|
|
||
| validator = Draft3Validator(schema) | ||
| errors = validator.iter_errors(instance) | ||
| e1, e2 = sorted_errors(errors) | ||
|
|
||
| self.assertEqual(list(e1.path), [1]) | ||
| self.assertEqual(list(e2.path), [2]) | ||
|
|
||
| self.assertEqual(e1.validator, "type") | ||
| self.assertEqual(e2.validator, "minimum") | ||
|
|
||
|
|
||
| class TestErrorTree(unittest.TestCase): | ||
| def setUp(self): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can provide len_items here as the start argument to
enumeraterather than adding manually.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, didn't know that.