diff options
author | Julian Berman <Julian@GrayVines.com> | 2020-08-26 08:43:09 -0400 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2020-08-26 08:43:09 -0400 |
commit | 32b4de4810ebafdb5f28a21c3aabd29b9e2d1880 (patch) | |
tree | 2b00320a478bb7107ea16d80677d493ac9f9d7cd /jsonschema/tests | |
parent | dc509218ffd4e4fabb35acd27cf3fb8678be2080 (diff) | |
download | jsonschema-32b4de4810ebafdb5f28a21c3aabd29b9e2d1880.tar.gz |
Simplify the schemas in the tests for CLI validator detection.
Diffstat (limited to 'jsonschema/tests')
-rw-r--r-- | jsonschema/tests/test_cli.py | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/jsonschema/tests/test_cli.py b/jsonschema/tests/test_cli.py index d0ca811..12c21a3 100644 --- a/jsonschema/tests/test_cli.py +++ b/jsonschema/tests/test_cli.py @@ -691,40 +691,36 @@ class TestCLI(TestCase): stderr="", ) - def test_draft07_check_const(self): + def test_it_validates_using_draft7_when_specified(self): + """ + Specifically, `const` validation applies for Draft 7. + """ schema = """ - { - "$schema": "http://json-schema.org/draft-07/schema#", - "properties": { - "value": { - "type": "string", - "const": "check" - } - } - } - """ - instance = """{"value": "2"}""" + { + "$schema": "http://json-schema.org/draft-07/schema#", + "const": "check" + } + """ + instance = '"foo"' self.assertOutputs( files=dict(some_schema=schema, some_instance=instance), argv=["-i", "some_instance", "some_schema"], exit_code=1, stdout="", - stderr="2: 'check' was expected\n", + stderr="foo: 'check' was expected\n", ) - def test_draft04_not_check_const(self): + def test_it_validates_using_draft4_when_specified(self): + """ + Specifically, `const` validation *does not* apply for Draft 4. + """ schema = """ - { - "$schema": "http://json-schema.org/draft-04/schema#", - "properties": { - "value": { - "type": "string", - "const": "check" - } - } - } - """ - instance = """{"value": "2"}""" + { + "$schema": "http://json-schema.org/draft-04/schema#", + "const": "check" + } + """ + instance = '"foo"' self.assertOutputs( files=dict(some_schema=schema, some_instance=instance), argv=["-i", "some_instance", "some_schema"], |