diff options
author | Julian Berman <Julian@GrayVines.com> | 2019-01-23 18:05:31 -0500 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2019-01-23 18:05:31 -0500 |
commit | 5559a31ddf9c45211ef8f15b15a294de14161340 (patch) | |
tree | 75e19c60d9d6f0e2d58a27961c58103d8e63f505 | |
parent | 207bb1ca96611916a8bea07a7bed2d94c0722e03 (diff) | |
download | jsonschema-5559a31ddf9c45211ef8f15b15a294de14161340.tar.gz |
Ensure error properties are properly set for boolean schemas.
-rw-r--r-- | jsonschema/tests/test_validators.py | 21 | ||||
-rw-r--r-- | jsonschema/validators.py | 4 |
2 files changed, 25 insertions, 0 deletions
diff --git a/jsonschema/tests/test_validators.py b/jsonschema/tests/test_validators.py index 9624c96..9308e32 100644 --- a/jsonschema/tests/test_validators.py +++ b/jsonschema/tests/test_validators.py @@ -953,6 +953,27 @@ class TestValidationErrorDetails(TestCase): self.assertEqual(error.path, deque([])) self.assertEqual(error.schema_path, deque(["if", "else", "const"])) + def test_boolean_schema_False(self): + validator = validators.Draft7Validator(False) + error, = validator.iter_errors(12) + + self.assertEqual( + ( + error.message, + error.validator, + error.validator_value, + error.instance, + error.schema, + ), + ( + "False schema does not allow 12", + None, + None, + 12, + False, + ), + ) + class MetaSchemaTestsMixin(object): # TODO: These all belong upstream diff --git a/jsonschema/validators.py b/jsonschema/validators.py index 557996a..90c0f1b 100644 --- a/jsonschema/validators.py +++ b/jsonschema/validators.py @@ -270,6 +270,10 @@ def create( elif _schema is False: yield exceptions.ValidationError( "False schema does not allow %r" % (instance,), + validator=None, + validator_value=None, + instance=instance, + schema=_schema, ) return |