Skip to content

Commit 53da77f

Browse files
committed
Update the sanity checker to use a version which supports 2019+.
It was previously skipping validating newer drafts :/ Refs: #562
1 parent d3f5cd4 commit 53da77f

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

.github/workflows/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ on:
66
release:
77
types: [published]
88
schedule:
9-
# Daily at 6:42
9+
# Daily at 6:42, arbitrarily as a time that's possibly non-busy
1010
- cron: '42 6 * * *'
1111

1212
jobs:
1313
ci:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v3
1818
- name: Set up Python
19-
uses: actions/setup-python@v2
19+
uses: actions/setup-python@v4
2020
with:
21-
python-version: 3.7
21+
python-version: '3.x'
2222
- name: Install tox
2323
run: python -m pip install tox
2424
- name: Run the sanity checks

bin/jsonschema_suite

+17-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ try:
1515
import jsonschema.validators
1616
except ImportError:
1717
jsonschema = None
18+
VALIDATORS = {}
19+
else:
20+
VALIDATORS = {
21+
"draft3": jsonschema.validators.Draft3Validator,
22+
"draft4": jsonschema.validators.Draft4Validator,
23+
"draft6": jsonschema.validators.Draft6Validator,
24+
"draft7": jsonschema.validators.Draft7Validator,
25+
"draft2019-09": jsonschema.validators.Draft201909Validator,
26+
"draft2020-12": jsonschema.validators.Draft202012Validator,
27+
"latest": jsonschema.validators.Draft202012Validator,
28+
}
1829

1930

2031
ROOT_DIR = os.path.abspath(
@@ -23,6 +34,7 @@ ROOT_DIR = os.path.abspath(
2334
SUITE_ROOT_DIR = os.path.join(ROOT_DIR, "tests")
2435
REMOTES_DIR = os.path.join(ROOT_DIR, "remotes")
2536

37+
2638
with open(os.path.join(ROOT_DIR, "test-schema.json")) as schema:
2739
TESTSUITE_SCHEMA = json.load(schema)
2840

@@ -114,13 +126,13 @@ class SanityTests(unittest.TestCase):
114126

115127
@unittest.skipIf(jsonschema is None, "Validation library not present!")
116128
def test_all_schemas_are_valid(self):
117-
for schema in os.listdir(SUITE_ROOT_DIR):
118-
schema_validator = jsonschema.validators.validators.get(schema)
119-
if schema_validator is not None:
120-
test_files = collect(os.path.join(SUITE_ROOT_DIR, schema))
129+
for version in os.listdir(SUITE_ROOT_DIR):
130+
Validator = VALIDATORS.get(version)
131+
if Validator is not None:
132+
test_files = collect(os.path.join(SUITE_ROOT_DIR, version))
121133
for case in cases(test_files):
122134
try:
123-
schema_validator.check_schema(case["schema"])
135+
Validator.check_schema(case["schema"])
124136
except jsonschema.SchemaError as error:
125137
self.fail("%s contains an invalid schema (%s)" %
126138
(case, error))

tox.ini

+1-1
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==3.2.0
8+
deps = jsonschema==4.6.1
99
commands = {envpython} bin/jsonschema_suite check

0 commit comments

Comments
 (0)