Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 32b4de4

Browse files
committed
Simplify the schemas in the tests for CLI validator detection.
1 parent dc50921 commit 32b4de4

1 file changed

Lines changed: 21 additions & 25 deletions

File tree

jsonschema/tests/test_cli.py

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -691,40 +691,36 @@ def test_real_validator(self):
691691
stderr="",
692692
)
693693

694-
def test_draft07_check_const(self):
694+
def test_it_validates_using_draft7_when_specified(self):
695+
"""
696+
Specifically, `const` validation applies for Draft 7.
697+
"""
695698
schema = """
696-
{
697-
"$schema": "http://json-schema.org/draft-07/schema#",
698-
"properties": {
699-
"value": {
700-
"type": "string",
701-
"const": "check"
702-
}
703-
}
704-
}
705-
"""
706-
instance = """{"value": "2"}"""
699+
{
700+
"$schema": "http://json-schema.org/draft-07/schema#",
701+
"const": "check"
702+
}
703+
"""
704+
instance = '"foo"'
707705
self.assertOutputs(
708706
files=dict(some_schema=schema, some_instance=instance),
709707
argv=["-i", "some_instance", "some_schema"],
710708
exit_code=1,
711709
stdout="",
712-
stderr="2: 'check' was expected\n",
710+
stderr="foo: 'check' was expected\n",
713711
)
714712

715-
def test_draft04_not_check_const(self):
713+
def test_it_validates_using_draft4_when_specified(self):
714+
"""
715+
Specifically, `const` validation *does not* apply for Draft 4.
716+
"""
716717
schema = """
717-
{
718-
"$schema": "http://json-schema.org/draft-04/schema#",
719-
"properties": {
720-
"value": {
721-
"type": "string",
722-
"const": "check"
723-
}
724-
}
725-
}
726-
"""
727-
instance = """{"value": "2"}"""
718+
{
719+
"$schema": "http://json-schema.org/draft-04/schema#",
720+
"const": "check"
721+
}
722+
"""
723+
instance = '"foo"'
728724
self.assertOutputs(
729725
files=dict(some_schema=schema, some_instance=instance),
730726
argv=["-i", "some_instance", "some_schema"],

0 commit comments

Comments
 (0)