Deprecate meta_validate too.
This commit is contained in:
@@ -684,5 +684,13 @@ def validate(instance, schema, cls=Draft3Validator, *args, **kwargs):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
meta_validate = kwargs.pop("meta_validate", None)
|
||||||
|
if meta_validate is not None:
|
||||||
|
warnings.warn(
|
||||||
|
"meta_validate is deprecated and will be removed. If you want to "
|
||||||
|
"validate a schema, use Draft3Validator.check_schema instead.",
|
||||||
|
DeprecationWarning, stacklevel=2,
|
||||||
|
)
|
||||||
|
|
||||||
validator = cls(schema, *args, **kwargs)
|
validator = cls(schema, *args, **kwargs)
|
||||||
validator.validate(instance)
|
validator.validate(instance)
|
||||||
|
|||||||
2
perftest
2
perftest
@@ -19,7 +19,7 @@ instance = schema = Draft3Validator.META_SCHEMA
|
|||||||
|
|
||||||
results = timeit.timeit(
|
results = timeit.timeit(
|
||||||
# Validate the Draft 3 meta-schema against itself without meta-validating
|
# Validate the Draft 3 meta-schema against itself without meta-validating
|
||||||
stmt="validate(instance, schema, meta_validate=False)",
|
stmt="validate(instance, schema)",
|
||||||
setup="from __main__ import instance, schema, validate",
|
setup="from __main__ import instance, schema, validate",
|
||||||
number=arguments.number,
|
number=arguments.number,
|
||||||
)
|
)
|
||||||
|
|||||||
8
tests.py
8
tests.py
@@ -908,6 +908,14 @@ class TestValidator(TestCase):
|
|||||||
self.assertEqual(len(w), 1)
|
self.assertEqual(len(w), 1)
|
||||||
|
|
||||||
|
|
||||||
|
class TestValidateFunction(TestCase):
|
||||||
|
def test_meta_validate_deprecated(self):
|
||||||
|
with warnings.catch_warnings(record=True) as w:
|
||||||
|
warnings.simplefilter("always")
|
||||||
|
validate("foo", {}, meta_validate=False)
|
||||||
|
self.assertEqual(len(w), 1)
|
||||||
|
|
||||||
|
|
||||||
class TestValidatorIterErrors(TestIterErrors):
|
class TestValidatorIterErrors(TestIterErrors):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.validator = Validator()
|
self.validator = Validator()
|
||||||
|
|||||||
Reference in New Issue
Block a user