Skip to content
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

Add convenience options for test suite config #106

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ of the test suite, jschon provides the following pytest command line options::

--testsuite-version={2019-09,2020-12,next}
JSON Schema version to test. The option may be repeated
to test multiple versions. (default: {2019-09,2020-12})
to test multiple versions, or the value 'all' can be used
to run all versions. (default: {2019-09,2020-12})
--testsuite-optionals
Include optional tests.
--testsuite-formats Include format tests.
--testsuite-all Include all possible JSON Schema test suite cases
(all versions, optionals, and formats).
--testsuite-file=TESTSUITE_FILE
Run only this file from the JSON Schema Test Suite.
Given as a path relative to the version directory in the
Expand Down
11 changes: 8 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def pytest_addoption(parser):
testsuite.addoption(
"--testsuite-version",
action="append",
choices=["2019-09", "2020-12", "next"],
help="JSON Schema version to test. The option may be repeated to test multiple versions. "
"(default: {2019-09,2020-12})",
choices=["2019-09", "2020-12", "next", "all"],
help="JSON Schema version to test. The option may be repeated to test multiple versions, "
"or the value 'all' can be used to run all versions. (default: {2019-09,2020-12})",
)
testsuite.addoption(
"--testsuite-optionals",
Expand All @@ -31,6 +31,11 @@ def pytest_addoption(parser):
action="store_true",
help="Include format tests.",
)
testsuite.addoption(
"--testsuite-all",
action="store_true",
help="Include all possible JSON Schema test suite cases (all versions, optionals, and formats).",
)
testsuite.addoption(
"--testsuite-file",
action="append",
Expand Down
9 changes: 7 additions & 2 deletions tests/test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from jschon.utils import json_loadf
from tests import metaschema_uri_2019_09, metaschema_uri_2020_12, metaschema_uri_next

ALL_VERSIONS = ('2019-09', '2020-12', 'next')

testsuite_dir = pathlib.Path(__file__).parent / 'JSON-Schema-Test-Suite'


Expand Down Expand Up @@ -95,9 +97,10 @@ def pytest_generate_tests(metafunc):
testids = []

gen_status_data = metafunc.config.getoption("testsuite_generate_status")
run_all = metafunc.config.getoption("testsuite_all")
status_data = SuiteStatus.get_instance(metafunc, gen_status_data)
if gen_status_data:
test_versions = ('2019-09', '2020-12', 'next')
if gen_status_data or run_all:
test_versions = ALL_VERSIONS
include_optionals = True
include_formats = True
test_files = []
Expand All @@ -111,6 +114,8 @@ def pytest_generate_tests(metafunc):

if not test_versions:
test_versions = ['2019-09', '2020-12']
elif test_versions == ['all']:
test_versions = ALL_VERSIONS

base_dir = testsuite_dir / 'tests'
version_dirs = {
Expand Down