File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1
1
from jsonschema import Draft4Validator , ValidationError , cli
2
2
from jsonschema .compat import StringIO
3
3
from jsonschema .tests .compat import mock , unittest
4
+ from jsonschema .exceptions import SchemaError
4
5
5
6
6
7
def fake_validator (* errors ):
@@ -14,6 +15,10 @@ def iter_errors(self, instance):
14
15
if errors :
15
16
return errors .pop ()
16
17
return []
18
+
19
+ def check_schema (self , schema ):
20
+ return True
21
+
17
22
return FakeValidator
18
23
19
24
@@ -55,6 +60,26 @@ def test_find_validator_in_jsonschema(self):
55
60
56
61
57
62
class TestCLI (unittest .TestCase ):
63
+ def test_draft3_schema_draft4_validator (self ):
64
+ stdout , stderr = StringIO (), StringIO ()
65
+ with self .assertRaises (SchemaError ):
66
+ exit_code = cli .run (
67
+ {
68
+ "validator" : Draft4Validator ,
69
+ "schema" : {
70
+ "anyOf" : [
71
+ {"minimum" : 20 },
72
+ {"type" : "string" },
73
+ {"required" : True }
74
+ ]
75
+ },
76
+ "instances" : [1 ],
77
+ "error_format" : "{error.message}" ,
78
+ },
79
+ stdout = stdout ,
80
+ stderr = stderr ,
81
+ )
82
+
58
83
def test_successful_validation (self ):
59
84
stdout , stderr = StringIO (), StringIO ()
60
85
exit_code = cli .run (
You can’t perform that action at this time.
0 commit comments