summaryrefslogtreecommitdiff
path: root/jsonschema/tests/test_deprecations.py
diff options
context:
space:
mode:
Diffstat (limited to 'jsonschema/tests/test_deprecations.py')
-rw-r--r--jsonschema/tests/test_deprecations.py36
1 files changed, 35 insertions, 1 deletions
diff --git a/jsonschema/tests/test_deprecations.py b/jsonschema/tests/test_deprecations.py
index 0ddc375..c1f4c21 100644
--- a/jsonschema/tests/test_deprecations.py
+++ b/jsonschema/tests/test_deprecations.py
@@ -1,6 +1,6 @@
from unittest import TestCase
-from jsonschema.validators import RefResolver
+from jsonschema.validators import Draft7Validator, RefResolver
class TestDeprecations(TestCase):
@@ -48,3 +48,37 @@ class TestDeprecations(TestCase):
"jsonschema.RefResolver.in_scope is deprecated ",
),
)
+
+ def test_Validator_is_valid_two_arguments(self):
+ """
+ As of v4.0.0, calling is_valid with two arguments (to provide a
+ different schema) is deprecated.
+ """
+
+ validator = Draft7Validator({})
+ with self.assertWarns(DeprecationWarning) as w:
+ result = validator.is_valid("foo", {"type": "number"})
+
+ self.assertFalse(result)
+ self.assertTrue(
+ str(w.warning).startswith(
+ "Passing a schema to Validator.is_valid is deprecated ",
+ ),
+ )
+
+ def test_Validator_iter_errors_two_arguments(self):
+ """
+ As of v4.0.0, calling iter_errors with two arguments (to provide a
+ different schema) is deprecated.
+ """
+
+ validator = Draft7Validator({})
+ with self.assertWarns(DeprecationWarning) as w:
+ error, = validator.iter_errors("foo", {"type": "number"})
+
+ self.assertEqual(error.validator, "type")
+ self.assertTrue(
+ str(w.warning).startswith(
+ "Passing a schema to Validator.iter_errors is deprecated ",
+ ),
+ )