Skip to content

Update the sanity checker to use a version which supports 2019+. #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ on:
release:
types: [published]
schedule:
# Daily at 6:42
# Daily at 6:42, arbitrarily as a time that's possibly non-busy
- cron: '42 6 * * *'

jobs:
ci:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: '3.x'
- name: Install tox
run: python -m pip install tox
- name: Run the sanity checks
Expand Down
22 changes: 17 additions & 5 deletions bin/jsonschema_suite
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ try:
import jsonschema.validators
except ImportError:
jsonschema = None
VALIDATORS = {}
else:
VALIDATORS = {
"draft3": jsonschema.validators.Draft3Validator,
"draft4": jsonschema.validators.Draft4Validator,
"draft6": jsonschema.validators.Draft6Validator,
"draft7": jsonschema.validators.Draft7Validator,
"draft2019-09": jsonschema.validators.Draft201909Validator,
"draft2020-12": jsonschema.validators.Draft202012Validator,
"latest": jsonschema.validators.Draft202012Validator,
}


ROOT_DIR = os.path.abspath(
Expand All @@ -23,6 +34,7 @@ ROOT_DIR = os.path.abspath(
SUITE_ROOT_DIR = os.path.join(ROOT_DIR, "tests")
REMOTES_DIR = os.path.join(ROOT_DIR, "remotes")


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

Expand Down Expand Up @@ -114,13 +126,13 @@ class SanityTests(unittest.TestCase):

@unittest.skipIf(jsonschema is None, "Validation library not present!")
def test_all_schemas_are_valid(self):
for schema in os.listdir(SUITE_ROOT_DIR):
schema_validator = jsonschema.validators.validators.get(schema)
if schema_validator is not None:
test_files = collect(os.path.join(SUITE_ROOT_DIR, schema))
for version in os.listdir(SUITE_ROOT_DIR):
Validator = VALIDATORS.get(version)
if Validator is not None:
test_files = collect(os.path.join(SUITE_ROOT_DIR, version))
for case in cases(test_files):
try:
schema_validator.check_schema(case["schema"])
Validator.check_schema(case["schema"])
except jsonschema.SchemaError as error:
self.fail("%s contains an invalid schema (%s)" %
(case, error))
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ skipsdist = True

[testenv:sanity]
# used just for validating the structure of the test case files themselves
deps = jsonschema==3.2.0
deps = jsonschema==4.6.1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(For reference later, this is the only line that really matters, it updates to a newer version. All the rest is just fixing a deprecation warning).

commands = {envpython} bin/jsonschema_suite check