from decimal import Decimal import sys import unittest from jsonschema import ( FormatError, SchemaError, ValidationError, Draft3Validator, Draft4Validator, Draft6Validator, FormatChecker, draft3_format_checker, draft4_format_checker, draft6_format_checker, validate, ) from jsonschema.compat import PY3 from jsonschema.tests.compat import mock from jsonschema.tests._suite import Suite from jsonschema.validators import create SUITE = Suite() DRAFT3 = SUITE.collection(name="draft3") DRAFT4 = SUITE.collection(name="draft4") DRAFT6 = SUITE.collection(name="draft6") def maybe_skip(skip, test_case, test): if skip is not None: reason = skip(test) if reason is not None: test_case = unittest.skip(reason)(test_case) return test_case def load_json_cases(tests, skip=None): def add_test_methods(test_class):
from jsonschema import ( Draft3Validator, Draft4Validator, Draft6Validator, Draft7Validator, draft3_format_checker, draft4_format_checker, draft6_format_checker, draft7_format_checker, ) from jsonschema.tests._helpers import bug from jsonschema.tests._suite import Suite from jsonschema.validators import _DEPRECATED_DEFAULT_TYPES, create SUITE = Suite() DRAFT3 = SUITE.version(name="draft3") DRAFT4 = SUITE.version(name="draft4") DRAFT6 = SUITE.version(name="draft6") DRAFT7 = SUITE.version(name="draft7") def skip(message, **kwargs): def skipper(test): if all(value == getattr(test, attr) for attr, value in kwargs.items()): return message return skipper def missing_format(checker): def missing_format(test):
#!/usr/bin/env python """ A performance benchmark using the official test suite. This benchmarks jsonschema using every valid example in the JSON-Schema-Test-Suite. It will take some time to complete. """ from jsonschema.tests._suite import Suite from perf import Runner if __name__ == "__main__": Suite().benchmark(runner=Runner())
from jsonschema import ( Draft3Validator, Draft4Validator, Draft6Validator, Draft7Validator, draft3_format_checker, draft4_format_checker, draft6_format_checker, draft7_format_checker, ) from jsonschema.tests._suite import Suite from jsonschema.validators import _DEPRECATED_DEFAULT_TYPES, create SUITE = Suite() DRAFT3 = SUITE.version(name="draft3") DRAFT4 = SUITE.version(name="draft4") DRAFT6 = SUITE.version(name="draft6") DRAFT7 = SUITE.version(name="draft7") def skip_tests_containing_descriptions(**kwargs): def skipper(test): descriptions_and_reasons = kwargs.get(test.subject, {}) return next( ( reason for description, reason in descriptions_and_reasons.items() if description in test.description ),
Draft4Validator, Draft6Validator, Draft7Validator, Draft201909Validator, Draft202012Validator, draft3_format_checker, draft4_format_checker, draft6_format_checker, draft7_format_checker, draft201909_format_checker, draft202012_format_checker, ) from jsonschema.tests._helpers import bug from jsonschema.tests._suite import Suite SUITE = Suite() DRAFT3 = SUITE.version(name="draft3") DRAFT4 = SUITE.version(name="draft4") DRAFT6 = SUITE.version(name="draft6") DRAFT7 = SUITE.version(name="draft7") DRAFT201909 = SUITE.version(name="draft2019-09") DRAFT202012 = SUITE.version(name="draft2020-12") def skip(message, **kwargs): def skipper(test): if all(value == getattr(test, attr) for attr, value in kwargs.items()): return message return skipper
from decimal import Decimal import sys import unittest from jsonschema import ( FormatError, SchemaError, ValidationError, Draft3Validator, Draft4Validator, FormatChecker, draft3_format_checker, draft4_format_checker, validate, ) from jsonschema.compat import PY3 from jsonschema.tests.compat import mock from jsonschema.tests._suite import Suite from jsonschema.validators import create SUITE = Suite() DRAFT3 = SUITE.collection(name="draft3") DRAFT4 = SUITE.collection(name="draft4") def maybe_skip(skip, test_case, test): if skip is not None: reason = skip(test) if reason is not None: test_case = unittest.skip(reason)(test_case) return test_case def load_json_cases(tests, skip=None): def add_test_methods(test_class): for test in tests: