Skip to content

Commit 89970e3

Browse files
committed
Get rid of the actual dependency on mock.
We're still patching in these two places, but can come back to fix that later. Closes: #335.
1 parent 9ff1b5e commit 89970e3

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

jsonschema/tests/compat.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

jsonschema/tests/test_validators.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
validators,
2222
)
2323
from jsonschema.compat import PY3, pathname2url
24-
from jsonschema.tests.compat import mock
2524

2625

2726
def startswith(validator, startswith, instance, schema):
@@ -1256,11 +1255,12 @@ def test_does_not_warn_if_meta_schema_is_unspecified(self):
12561255
self.assertFalse(self.flushWarnings())
12571256

12581257

1259-
class TestValidate(TestCase):
1258+
class TestValidate(SynchronousTestCase):
12601259
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])
12641264

12651265
def test_draft3_validator_is_chosen(self):
12661266
self.assertUses(
@@ -1326,7 +1326,7 @@ def test_schema_error_message(self):
13261326
)
13271327

13281328

1329-
class TestRefResolver(TestCase):
1329+
class TestRefResolver(SynchronousTestCase):
13301330

13311331
base_uri = ""
13321332
stored_uri = "foo://stored"
@@ -1341,14 +1341,14 @@ def setUp(self):
13411341

13421342
def test_it_does_not_retrieve_schema_urls_from_the_network(self):
13431343
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!"),
13501348
)
1351-
self.assertFalse(remote.called)
1349+
with self.resolver.resolving(ref) as resolved:
1350+
pass
1351+
self.assertEqual(resolved, validators.Draft3Validator.META_SCHEMA)
13521352

13531353
def test_it_resolves_local_refs(self):
13541354
ref = "#/properties/foo"

test-requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
git+https://github.com/Julian/betterpath#egg=betterpath
2-
mock

0 commit comments

Comments
 (0)