diff options
Diffstat (limited to 'jsonschema/tests')
-rw-r--r-- | jsonschema/tests/_suite.py | 6 | ||||
-rw-r--r-- | jsonschema/tests/test_cli.py | 12 | ||||
-rw-r--r-- | jsonschema/tests/test_exceptions.py | 2 | ||||
-rw-r--r-- | jsonschema/tests/test_format.py | 4 | ||||
-rw-r--r-- | jsonschema/tests/test_jsonschema_test_suite.py | 2 | ||||
-rw-r--r-- | jsonschema/tests/test_validators.py | 73 |
6 files changed, 42 insertions, 57 deletions
diff --git a/jsonschema/tests/_suite.py b/jsonschema/tests/_suite.py index 4d21f98..1c61363 100644 --- a/jsonschema/tests/_suite.py +++ b/jsonschema/tests/_suite.py @@ -143,7 +143,7 @@ class Version(object): case_description=each["description"], schema=each["schema"], remotes=self._remotes, - **test + **test, ) for test in each["tests"] ) @@ -177,7 +177,7 @@ class _Test(object): self.subject, self.case_description, self.description, - ] + ], ) @property @@ -213,7 +213,7 @@ class _Test(object): schema=self.schema, cls=Validator, resolver=resolver, - **kwargs + **kwargs, ) def validate_ignoring_errors(self, Validator): # pragma: no cover diff --git a/jsonschema/tests/test_cli.py b/jsonschema/tests/test_cli.py index ae4f13d..fa29b48 100644 --- a/jsonschema/tests/test_cli.py +++ b/jsonschema/tests/test_cli.py @@ -59,7 +59,7 @@ def _message_for(non_json): class TestCLI(TestCase): def run_cli( - self, argv, files={}, stdin=StringIO(), exit_code=0, **override + self, argv, files={}, stdin=StringIO(), exit_code=0, **override, ): arguments = cli.parse_args(argv) arguments.update(override) @@ -134,7 +134,7 @@ class TestCLI(TestCase): I am an error! ----------------------------- """, - ), + ) def test_invalid_instance_explicit_plain_output(self): error = ValidationError("I am an error!", instance=12) @@ -835,7 +835,7 @@ class TestParser(TestCase): "jsonschema.tests.test_cli.TestParser.FakeValidator", "--instance", "mem://some/instance", "mem://some/schema", - ] + ], ) self.assertIs(arguments["validator"], self.FakeValidator) @@ -845,7 +845,7 @@ class TestParser(TestCase): "--validator", "Draft4Validator", "--instance", "mem://some/instance", "mem://some/schema", - ] + ], ) self.assertIs(arguments["validator"], Draft4Validator) @@ -857,7 +857,7 @@ class TestParser(TestCase): [ "--output", "foo", "mem://some/schema", - ] + ], ) self.assertIn("invalid choice: 'foo'", stderr.getvalue()) self.assertFalse(stdout.getvalue()) @@ -871,7 +871,7 @@ class TestParser(TestCase): "--output", "pretty", "--error-format", "foo", "mem://some/schema", - ] + ], ) self.assertIn( "--error-format can only be used with --output plain", diff --git a/jsonschema/tests/test_exceptions.py b/jsonschema/tests/test_exceptions.py index a285550..788d316 100644 --- a/jsonschema/tests/test_exceptions.py +++ b/jsonschema/tests/test_exceptions.py @@ -41,7 +41,7 @@ class TestBestMatch(TestCase): "minProperties": 2, "anyOf": [{"type": "string"}, {"type": "number"}], "oneOf": [{"type": "string"}, {"type": "number"}], - } + }, ) best = self.best_match(validator.iter_errors({})) self.assertEqual(best.validator, "minProperties") diff --git a/jsonschema/tests/test_format.py b/jsonschema/tests/test_format.py index 06f841c..1846cb2 100644 --- a/jsonschema/tests/test_format.py +++ b/jsonschema/tests/test_format.py @@ -40,7 +40,7 @@ class TestFormatChecker(TestCase): checker.checks("boom")(boom) self.assertEqual( checker.checkers, - dict(FormatChecker.checkers, boom=(boom, ())) + dict(FormatChecker.checkers, boom=(boom, ())), ) def test_it_catches_registered_errors(self): @@ -102,6 +102,6 @@ class TestFormatChecker(TestCase): checker = FormatChecker() self.assertTrue(checker.conforms(1, "uuid")) self.assertTrue( - checker.conforms("6e6659ec-4503-4428-9f03-2e2ea4d6c278", "uuid") + checker.conforms("6e6659ec-4503-4428-9f03-2e2ea4d6c278", "uuid"), ) self.assertFalse(checker.conforms("test", "uuid")) diff --git a/jsonschema/tests/test_jsonschema_test_suite.py b/jsonschema/tests/test_jsonschema_test_suite.py index b1e0723..1d8a804 100644 --- a/jsonschema/tests/test_jsonschema_test_suite.py +++ b/jsonschema/tests/test_jsonschema_test_suite.py @@ -459,5 +459,5 @@ TestDraft202012Format = DRAFT202012.to_unittest_testcase( or leap_second(test) or missing_format(draft202012_format_checker)(test) or complex_email_validation(test) - ) + ), ) diff --git a/jsonschema/tests/test_validators.py b/jsonschema/tests/test_validators.py index bb3fefb..65969bd 100644 --- a/jsonschema/tests/test_validators.py +++ b/jsonschema/tests/test_validators.py @@ -288,7 +288,7 @@ class TestValidationErrorMessages(TestCase): def test_additionalItems_multiple_failures(self): message = self.message_for( instance=[1, 2, 3], - schema={u"items": [], u"additionalItems": False} + schema={u"items": [], u"additionalItems": False}, ) self.assertIn("(1, 2, 3 were unexpected)", message) @@ -371,7 +371,7 @@ class TestValidationErrorMessages(TestCase): self.assertEqual( message, "{}, {} do not match any of the regexes: {}, {}".format( - repr(u"fish"), repr(u"zebra"), repr(u"^abc$"), repr(u"^def$") + repr(u"fish"), repr(u"zebra"), repr(u"^abc$"), repr(u"^def$"), ), ) @@ -384,10 +384,7 @@ class TestValidationErrorMessages(TestCase): self.assertIn("False schema does not allow 'something'", message) def test_unevaluated_properties(self): - schema = { - "type": "object", - "unevaluatedProperties": False - } + schema = {"type": "object", "unevaluatedProperties": False} message = self.message_for( instance={ "foo": "foo", @@ -403,10 +400,7 @@ class TestValidationErrorMessages(TestCase): ) def test_unevaluated_items(self): - schema = { - "type": "array", - "unevaluatedItems": False - } + schema = {"type": "array", "unevaluatedItems": False} message = self.message_for( instance=["foo", "bar"], schema=schema, @@ -654,7 +648,7 @@ class TestValidationErrorDetails(TestCase): ) self.assertEqual( list(e5.schema_path), - ["items", "properties", "bar", "properties", "baz", "minItems"] + ["items", "properties", "bar", "properties", "baz", "minItems"], ) self.assertEqual( list(e6.schema_path), ["items", "properties", "foo", "enum"], @@ -1047,7 +1041,7 @@ class ValidatorTestMixin(MetaSchemaTestsMixin, object): lambda checker, thing: isinstance( thing, (int, float, Decimal), ) and not isinstance(thing, bool), - ) + ), ) validator = Validator(schema) @@ -1101,7 +1095,7 @@ class ValidatorTestMixin(MetaSchemaTestsMixin, object): type_checker=self.Validator.TYPE_CHECKER.redefine( non_string_type, lambda checker, thing: isinstance(thing, int), - ) + ), ) Crazy(schema).validate(15) @@ -1116,7 +1110,7 @@ class ValidatorTestMixin(MetaSchemaTestsMixin, object): type_checker=self.Validator.TYPE_CHECKER.redefine( "array", lambda checker, thing: isinstance(thing, tuple), - ) + ), ) with self.assertRaises(exceptions.ValidationError) as e: TupleValidator({"uniqueItems": True}).validate((1, 1)) @@ -1126,21 +1120,20 @@ class ValidatorTestMixin(MetaSchemaTestsMixin, object): """ Allow array to validate against another defined sequence type """ - schema = { - "type": "array", - "uniqueItems": True - } + schema = {"type": "array", "uniqueItems": True} MyMapping = namedtuple('MyMapping', 'a, b') Validator = validators.extend( self.Validator, - type_checker=self.Validator.TYPE_CHECKER.redefine_many({ - "array": lambda checker, thing: isinstance( - thing, (list, deque) - ), - "object": lambda checker, thing: isinstance( - thing, (dict, MyMapping) - ), - }) + type_checker=self.Validator.TYPE_CHECKER.redefine_many( + { + "array": lambda checker, thing: isinstance( + thing, (list, deque), + ), + "object": lambda checker, thing: isinstance( + thing, (dict, MyMapping), + ), + }, + ), ) validator = Validator(schema) @@ -1154,15 +1147,11 @@ class ValidatorTestMixin(MetaSchemaTestsMixin, object): [MyMapping('a', 0), MyMapping('a', False)], [ MyMapping('a', [deque([0])]), - MyMapping('a', [deque([False])]) + MyMapping('a', [deque([False])]), ], [ - MyMapping('a', [ - MyMapping('a', deque([0])) - ]), - MyMapping('a', [ - MyMapping('a', deque([False])) - ]) + MyMapping('a', [MyMapping('a', deque([0]))]), + MyMapping('a', [MyMapping('a', deque([False]))]), ], [deque(deque(deque([False]))), deque(deque(deque([0])))], ] @@ -1180,15 +1169,11 @@ class ValidatorTestMixin(MetaSchemaTestsMixin, object): [MyMapping('a', False), MyMapping('a', False)], [ MyMapping('a', [deque([False])]), - MyMapping('a', [deque([False])]) + MyMapping('a', [deque([False])]), ], [ - MyMapping('a', [ - MyMapping('a', deque([False])) - ]), - MyMapping('a', [ - MyMapping('a', deque([False])) - ]) + MyMapping('a', [MyMapping('a', deque([False]))]), + MyMapping('a', [MyMapping('a', deque([False]))]), ], [deque(deque(deque([False]))), deque(deque(deque([False])))], ] @@ -1245,7 +1230,7 @@ class TestDraft3Validator(AntiDraft6LeakMixin, ValidatorTestMixin, TestCase): self.Validator, type_checker=self.Validator.TYPE_CHECKER.redefine( "any", lambda checker, thing: isinstance(thing, int), - ) + ), ) validator = Crazy({"type": "any"}) validator.validate(12) @@ -1408,7 +1393,7 @@ class TestValidatorFor(SynchronousTestCase): ) def test_does_not_warn_if_meta_schema_is_unspecified(self): - validators.validator_for(schema={}, default={}), + validators.validator_for(schema={}, default={}) self.assertFalse(self.flushWarnings()) @@ -1466,14 +1451,14 @@ class TestValidate(SynchronousTestCase): def test_draft202012_validator_is_chosen(self): self.assertUses( schema={ - "$schema": "https://json-schema.org/draft/2020-12/schema#" + "$schema": "https://json-schema.org/draft/2020-12/schema#", }, Validator=validators.Draft202012Validator, ) # Make sure it works without the empty fragment self.assertUses( schema={ - "$schema": "https://json-schema.org/draft/2020-12/schema" + "$schema": "https://json-schema.org/draft/2020-12/schema", }, Validator=validators.Draft202012Validator, ) |