11from collections import deque
22from contextlib import contextmanager
3+ from unittest import TestCase
34import json
45
56from jsonschema import FormatChecker , SchemaError , ValidationError
6- from jsonschema .tests .compat import mock , unittest
7+ from jsonschema .tests .compat import mock
78from jsonschema .validators import (
89 RefResolutionError , UnknownType , Draft3Validator ,
910 Draft4Validator , RefResolver , create , extend , validator_for , validate ,
1011)
1112
1213
13- class TestCreateAndExtend (unittest . TestCase ):
14+ class TestCreateAndExtend (TestCase ):
1415 def setUp (self ):
1516 self .meta_schema = {u"properties" : {u"smelly" : {}}}
1617 self .smelly = mock .MagicMock ()
@@ -74,7 +75,7 @@ def test_extend(self):
7475 self .assertEqual (Extended .DEFAULT_TYPES , self .Validator .DEFAULT_TYPES )
7576
7677
77- class TestIterErrors (unittest . TestCase ):
78+ class TestIterErrors (TestCase ):
7879 def setUp (self ):
7980 self .validator = Draft3Validator ({})
8081
@@ -108,7 +109,7 @@ def test_iter_errors_multiple_failures_one_validator(self):
108109 self .assertEqual (len (errors ), 4 )
109110
110111
111- class TestValidationErrorMessages (unittest . TestCase ):
112+ class TestValidationErrorMessages (TestCase ):
112113 def message_for (self , instance , schema , * args , ** kwargs ):
113114 kwargs .setdefault ("cls" , Draft3Validator )
114115 with self .assertRaises (ValidationError ) as e :
@@ -216,7 +217,7 @@ def test_additionalProperties_false_patternProperties(self):
216217 )
217218
218219
219- class TestValidationErrorDetails (unittest . TestCase ):
220+ class TestValidationErrorDetails (TestCase ):
220221 # TODO: These really need unit tests for each individual validator, rather
221222 # than just these higher level tests.
222223 def test_anyOf (self ):
@@ -692,7 +693,7 @@ def test_is_type_raises_exception_for_unknown_type(self):
692693 self .validator .is_type ("foo" , object ())
693694
694695
695- class TestDraft3Validator (ValidatorTestMixin , unittest . TestCase ):
696+ class TestDraft3Validator (ValidatorTestMixin , TestCase ):
696697 validator_class = Draft3Validator
697698
698699 def test_is_type_is_true_for_any_type (self ):
@@ -708,11 +709,11 @@ def test_non_string_custom_types(self):
708709 cls .validate (None , schema )
709710
710711
711- class TestDraft4Validator (ValidatorTestMixin , unittest . TestCase ):
712+ class TestDraft4Validator (ValidatorTestMixin , TestCase ):
712713 validator_class = Draft4Validator
713714
714715
715- class TestBuiltinFormats (unittest . TestCase ):
716+ class TestBuiltinFormats (TestCase ):
716717 """
717718 The built-in (specification-defined) formats do not raise type errors.
718719
@@ -732,7 +733,7 @@ def test(self, format=format):
732733 del test # Ugh py.test. Stop discovering top level tests.
733734
734735
735- class TestValidatorFor (unittest . TestCase ):
736+ class TestValidatorFor (TestCase ):
736737 def test_draft_3 (self ):
737738 schema = {"$schema" : "http://json-schema.org/draft-03/schema" }
738739 self .assertIs (validator_for (schema ), Draft3Validator )
@@ -759,7 +760,7 @@ def test_validator_for_custom_default(self):
759760 self .assertIs (validator_for ({}, default = None ), None )
760761
761762
762- class TestValidate (unittest . TestCase ):
763+ class TestValidate (TestCase ):
763764 def test_draft3_validator_is_chosen (self ):
764765 schema = {"$schema" : "http://json-schema.org/draft-03/schema#" }
765766 with mock .patch .object (Draft3Validator , "check_schema" ) as chk_schema :
@@ -799,7 +800,7 @@ def test_schema_error_message(self):
799800 )
800801
801802
802- class TestRefResolver (unittest . TestCase ):
803+ class TestRefResolver (TestCase ):
803804
804805 base_uri = ""
805806 stored_uri = "foo://stored"
@@ -951,11 +952,11 @@ def test_it_properly_formats_an_error_message(self):
951952 self .assertIn ("(1, 1) has non-unique elements" , str (e .exception ))
952953
953954
954- class TestDraft4UniqueTupleItems (UniqueTupleItemsMixin , unittest . TestCase ):
955+ class TestDraft4UniqueTupleItems (UniqueTupleItemsMixin , TestCase ):
955956 validator_class = Draft4Validator
956957
957958
958- class TestDraft3UniqueTupleItems (UniqueTupleItemsMixin , unittest . TestCase ):
959+ class TestDraft3UniqueTupleItems (UniqueTupleItemsMixin , TestCase ):
959960 validator_class = Draft3Validator
960961
961962
0 commit comments