diff options
author | morpheus65535 <[email protected]> | 2024-03-03 12:15:23 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2024-03-03 12:15:23 -0500 |
commit | 03afeb347075381bcb7fd6036295c9fa4a90d2dc (patch) | |
tree | 7c5d72c973d2c8e4ade57391a1c9ad5e94903a46 /libs/jsonschema/tests | |
parent | 9ae684240b5bdd40a870d8122f0e380f8d03a187 (diff) | |
download | bazarr-03afeb347075381bcb7fd6036295c9fa4a90d2dc.tar.gz bazarr-03afeb347075381bcb7fd6036295c9fa4a90d2dc.zip |
Updated multiple Python modules (now in libs and custom_libs directories) and React libraries
Diffstat (limited to 'libs/jsonschema/tests')
-rw-r--r-- | libs/jsonschema/tests/test_deprecations.py | 17 | ||||
-rw-r--r-- | libs/jsonschema/tests/test_jsonschema_test_suite.py | 2 | ||||
-rw-r--r-- | libs/jsonschema/tests/test_validators.py | 36 |
3 files changed, 54 insertions, 1 deletions
diff --git a/libs/jsonschema/tests/test_deprecations.py b/libs/jsonschema/tests/test_deprecations.py index 54acd86c6..3e8a9cc47 100644 --- a/libs/jsonschema/tests/test_deprecations.py +++ b/libs/jsonschema/tests/test_deprecations.py @@ -1,4 +1,5 @@ from unittest import TestCase +import importlib import subprocess import sys @@ -264,6 +265,22 @@ class TestDeprecations(TestCase): with self.assertRaises(ImportError): from jsonschema import draft1234_format_checker # noqa + def test_import_cli(self): + """ + As of v4.17.0, importing jsonschema.cli is deprecated. + """ + + with self.assertWarns(DeprecationWarning) as w: + import jsonschema.cli + importlib.reload(jsonschema.cli) + + self.assertEqual(w.filename, importlib.__file__) + self.assertTrue( + str(w.warning).startswith( + "The jsonschema CLI is deprecated and will be removed ", + ), + ) + def test_cli(self): """ As of v4.17.0, the jsonschema CLI is deprecated. diff --git a/libs/jsonschema/tests/test_jsonschema_test_suite.py b/libs/jsonschema/tests/test_jsonschema_test_suite.py index 1e583659a..42337ed48 100644 --- a/libs/jsonschema/tests/test_jsonschema_test_suite.py +++ b/libs/jsonschema/tests/test_jsonschema_test_suite.py @@ -407,6 +407,7 @@ TestDraft201909 = DRAFT201909.to_unittest_testcase( TestDraft201909Format = DRAFT201909.to_unittest_testcase( DRAFT201909.format_tests(), + name="TestDraft201909Format", Validator=jsonschema.Draft201909Validator, format_checker=jsonschema.Draft201909Validator.FORMAT_CHECKER, skip=lambda test: ( @@ -532,6 +533,7 @@ TestDraft202012 = DRAFT202012.to_unittest_testcase( TestDraft202012Format = DRAFT202012.to_unittest_testcase( DRAFT202012.format_tests(), + name="TestDraft202012Format", Validator=jsonschema.Draft202012Validator, format_checker=jsonschema.Draft202012Validator.FORMAT_CHECKER, skip=lambda test: ( diff --git a/libs/jsonschema/tests/test_validators.py b/libs/jsonschema/tests/test_validators.py index 12c9dc9db..ec76a3e32 100644 --- a/libs/jsonschema/tests/test_validators.py +++ b/libs/jsonschema/tests/test_validators.py @@ -634,7 +634,26 @@ class TestValidationErrorMessages(TestCase): message = self.message_for(instance="foo", schema=schema) self.assertEqual(message, "'foo' is not of type 'array'") - def test_unevaluated_properties(self): + def test_unevaluated_properties_invalid_against_subschema(self): + schema = { + "properties": {"foo": {"type": "string"}}, + "unevaluatedProperties": {"const": 12}, + } + message = self.message_for( + instance={ + "foo": "foo", + "bar": "bar", + "baz": 12, + }, + schema=schema, + ) + self.assertEqual( + message, + "Unevaluated properties are not valid under the given schema " + "('bar' was unevaluated and invalid)", + ) + + def test_unevaluated_properties_disallowed(self): schema = {"type": "object", "unevaluatedProperties": False} message = self.message_for( instance={ @@ -1829,6 +1848,21 @@ class TestDraft202012Validator(ValidatorTestMixin, TestCase): invalid = {"type": "integer"}, "foo" +class TestLatestValidator(TestCase): + """ + These really apply to multiple versions but are easiest to test on one. + """ + + def test_ref_resolvers_may_have_boolean_schemas_stored(self): + ref = "someCoolRef" + schema = {"$ref": ref} + resolver = validators.RefResolver("", {}, store={ref: False}) + validator = validators._LATEST_VERSION(schema, resolver=resolver) + + with self.assertRaises(exceptions.ValidationError): + validator.validate(None) + + class TestValidatorFor(TestCase): def test_draft_3(self): schema = {"$schema": "http://json-schema.org/draft-03/schema"} |