summaryrefslogtreecommitdiff
path: root/jsonschema/tests
diff options
context:
space:
mode:
Diffstat (limited to 'jsonschema/tests')
-rw-r--r--jsonschema/tests/test_jsonschema_test_suite.py34
-rw-r--r--jsonschema/tests/test_validators.py30
2 files changed, 61 insertions, 3 deletions
diff --git a/jsonschema/tests/test_jsonschema_test_suite.py b/jsonschema/tests/test_jsonschema_test_suite.py
index 110c5f4..e434f8a 100644
--- a/jsonschema/tests/test_jsonschema_test_suite.py
+++ b/jsonschema/tests/test_jsonschema_test_suite.py
@@ -12,9 +12,11 @@ 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
@@ -24,6 +26,7 @@ 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):
@@ -139,6 +142,37 @@ TestDraft6 = DRAFT6.to_unittest_testcase(
)
+TestDraft7 = DRAFT7.to_unittest_testcase(
+ DRAFT7.tests(),
+ DRAFT7.format_tests(),
+ DRAFT7.optional_tests_of(name="bignum"),
+ DRAFT7.optional_tests_of(name="zeroTerminatedFloats"),
+ Validator=Draft7Validator,
+ format_checker=draft7_format_checker,
+ skip=lambda test: (
+ narrow_unicode_build(test)
+ or missing_format(draft7_format_checker)(test)
+ or skip_tests_containing_descriptions(
+ ref={
+ "valid tree": "An actual bug, this needs fixing.",
+ },
+ refRemote={
+ "number is valid": "An actual bug, this needs fixing.",
+ "string is invalid": "An actual bug, this needs fixing.",
+ },
+ )(test)
+ or skip_tests_containing_descriptions(
+ **{
+ "date-time": {
+ "case-insensitive T and Z":
+ "Upstream bug in strict_rfc3339",
+ },
+ }
+ )(test)
+ ),
+)
+
+
TestDraft3LegacyTypeCheck = DRAFT3.to_unittest_testcase(
DRAFT3.tests_of(name="type"),
name="TestDraft3LegacyTypeCheck",
diff --git a/jsonschema/tests/test_validators.py b/jsonschema/tests/test_validators.py
index 9ebff12..8bb3880 100644
--- a/jsonschema/tests/test_validators.py
+++ b/jsonschema/tests/test_validators.py
@@ -464,7 +464,7 @@ class TestValidationErrorMessages(TestCase):
message = self.message_for(
instance="something",
schema=False,
- cls=validators.Draft6Validator,
+ cls=validators.Draft7Validator,
)
self.assertIn("False schema does not allow 'something'", message)
@@ -1132,6 +1132,19 @@ class TestValidatorFor(TestCase):
validators.Draft6Validator,
)
+ def test_draft_7(self):
+ schema = {"$schema": "http://json-schema.org/draft-07/schema"}
+ self.assertIs(
+ validators.validator_for(schema),
+ validators.Draft7Validator,
+ )
+
+ schema = {"$schema": "http://json-schema.org/draft-07/schema#"}
+ self.assertIs(
+ validators.validator_for(schema),
+ validators.Draft7Validator,
+ )
+
def test_True(self):
self.assertIs(
validators.validator_for(True),
@@ -1213,8 +1226,19 @@ class TestValidate(TestCase):
Validator=validators.Draft6Validator,
)
- def test_draft6_validator_is_the_default(self):
- self.assertUses(schema={}, Validator=validators.Draft6Validator)
+ def test_draft7_validator_is_chosen(self):
+ self.assertUses(
+ schema={"$schema": "http://json-schema.org/draft-07/schema#"},
+ Validator=validators.Draft7Validator,
+ )
+ # Make sure it works without the empty fragment
+ self.assertUses(
+ schema={"$schema": "http://json-schema.org/draft-07/schema"},
+ Validator=validators.Draft7Validator,
+ )
+
+ def test_draft7_validator_is_the_default(self):
+ self.assertUses(schema={}, Validator=validators.Draft7Validator)
def test_validation_error_message(self):
with self.assertRaises(ValidationError) as e: