diff options
author | Julian Berman <Julian@GrayVines.com> | 2021-08-23 11:51:25 +0100 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2021-08-23 11:51:33 +0100 |
commit | 641e9b8cf898928b4e4257e1e5cda243fc1f1aa7 (patch) | |
tree | 3f160114be4e6c6b27d9f02761dbf53cf5cd9982 | |
parent | 0b7315c5e6b0b58d5d6ab3539cb52982231181c8 (diff) | |
download | jsonschema-641e9b8cf898928b4e4257e1e5cda243fc1f1aa7.tar.gz |
Slightly nicer error message for not.
-rw-r--r-- | jsonschema/_validators.py | 5 | ||||
-rw-r--r-- | jsonschema/tests/test_validators.py | 2 |
2 files changed, 3 insertions, 4 deletions
diff --git a/jsonschema/_validators.py b/jsonschema/_validators.py index 7f05505..e4cfa35 100644 --- a/jsonschema/_validators.py +++ b/jsonschema/_validators.py @@ -397,9 +397,8 @@ def oneOf(validator, oneOf, instance, schema): def not_(validator, not_schema, instance, schema): if validator.is_valid(instance, not_schema): - yield ValidationError( - f"{not_schema!r} is not allowed for {instance!r}", - ) + message = f"{instance!r} should not be valid under {not_schema!r}" + yield ValidationError(message) def if_(validator, if_schema, instance, schema): diff --git a/jsonschema/tests/test_validators.py b/jsonschema/tests/test_validators.py index 36d41d3..7f5f387 100644 --- a/jsonschema/tests/test_validators.py +++ b/jsonschema/tests/test_validators.py @@ -1022,7 +1022,7 @@ class TestValidationErrorDetails(TestCase): self.assertEqual(error.validator, "not") self.assertEqual( error.message, - "{'const': 'foo'} is not allowed for 'foo'", + "'foo' should not be valid under {'const': 'foo'}", ) self.assertEqual(error.path, deque([])) self.assertEqual(error.json_path, "$") |