21
21
validators ,
22
22
)
23
23
from jsonschema .compat import PY3 , pathname2url
24
- from jsonschema .tests .compat import mock
25
24
26
25
27
26
def startswith (validator , startswith , instance , schema ):
@@ -1256,11 +1255,12 @@ def test_does_not_warn_if_meta_schema_is_unspecified(self):
1256
1255
self .assertFalse (self .flushWarnings ())
1257
1256
1258
1257
1259
- class TestValidate (TestCase ):
1258
+ class TestValidate (SynchronousTestCase ):
1260
1259
def assertUses (self , schema , Validator ):
1261
- with mock .patch .object (Validator , "check_schema" ) as check_schema :
1262
- validators .validate ({}, schema )
1263
- check_schema .assert_called_once_with (schema )
1260
+ result = []
1261
+ self .patch (Validator , "check_schema" , result .append )
1262
+ validators .validate ({}, schema )
1263
+ self .assertEqual (result , [schema ])
1264
1264
1265
1265
def test_draft3_validator_is_chosen (self ):
1266
1266
self .assertUses (
@@ -1326,7 +1326,7 @@ def test_schema_error_message(self):
1326
1326
)
1327
1327
1328
1328
1329
- class TestRefResolver (TestCase ):
1329
+ class TestRefResolver (SynchronousTestCase ):
1330
1330
1331
1331
base_uri = ""
1332
1332
stored_uri = "foo://stored"
@@ -1341,14 +1341,14 @@ def setUp(self):
1341
1341
1342
1342
def test_it_does_not_retrieve_schema_urls_from_the_network (self ):
1343
1343
ref = validators .Draft3Validator .META_SCHEMA ["id" ]
1344
- with mock .patch .object (self .resolver , "resolve_remote" ) as remote :
1345
- with self .resolver .resolving (ref ) as resolved :
1346
- pass
1347
- self .assertEqual (
1348
- resolved ,
1349
- validators .Draft3Validator .META_SCHEMA ,
1344
+ self .patch (
1345
+ self .resolver ,
1346
+ "resolve_remote" ,
1347
+ lambda * args , ** kwargs : self .fail ("Should not have been called!" ),
1350
1348
)
1351
- self .assertFalse (remote .called )
1349
+ with self .resolver .resolving (ref ) as resolved :
1350
+ pass
1351
+ self .assertEqual (resolved , validators .Draft3Validator .META_SCHEMA )
1352
1352
1353
1353
def test_it_resolves_local_refs (self ):
1354
1354
ref = "#/properties/foo"
0 commit comments