Skip to content

Commit 49c6197

Browse files
committed
Future-proof the sanity checker for #238.
1 parent 3999497 commit 49c6197

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

bin/jsonschema_suite

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@ if getattr(unittest, "skipIf", None) is None:
1717
unittest.skipIf = lambda cond, msg : lambda fn : fn
1818

1919
try:
20-
import jsonschema
20+
import jsonschema.validators
2121
except ImportError:
2222
jsonschema = None
23-
else:
24-
validators = getattr(
25-
jsonschema.validators, "validators", jsonschema.validators
26-
)
2723

2824

2925
ROOT_DIR = os.path.abspath(
@@ -120,7 +116,7 @@ class SanityTests(unittest.TestCase):
120116
@unittest.skipIf(jsonschema is None, "Validation library not present!")
121117
def test_all_schemas_are_valid(self):
122118
for schema in os.listdir(SUITE_ROOT_DIR):
123-
schema_validator = validators.get(schema)
119+
schema_validator = jsonschema.validators.validators.get(schema)
124120
if schema_validator is not None:
125121
test_files = collect(os.path.join(SUITE_ROOT_DIR, schema))
126122
for case in cases(test_files):
@@ -134,7 +130,8 @@ class SanityTests(unittest.TestCase):
134130

135131
@unittest.skipIf(jsonschema is None, "Validation library not present!")
136132
def test_suites_are_valid(self):
137-
validator = jsonschema.Draft4Validator(TESTSUITE_SCHEMA)
133+
Validator = jsonschema.validators.validator_for(TESTSUITE_SCHEMA)
134+
validator = Validator(TESTSUITE_SCHEMA)
138135
for tests in files(self.test_files):
139136
try:
140137
validator.validate(tests)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ skipsdist = True
55

66
[testenv:sanity]
77
# used just for validating the structure of the test case files themselves
8-
deps = jsonschema
8+
deps = jsonschema>=3.2.0
99
commands = {envpython} bin/jsonschema_suite check

0 commit comments

Comments
 (0)