summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNozomi Kawamoto <nkawamot@redhat.com>2023-02-25 00:33:46 +0900
committerNozomi Kawamoto <nkawamot@redhat.com>2023-02-25 00:33:46 +0900
commitd52fb8cb6d2ed8893bc36f2f1f786cd890b1732e (patch)
treee7aa1bd43ef69580479be62257fddc454deeb5c3
parent07d83abc6b5037f28bffb3aa0dc51d114b63af5a (diff)
downloadtempest-d52fb8cb6d2ed8893bc36f2f1f786cd890b1732e.tar.gz
Fix DeprecationWarning of jsonschema
`jsonschema.draft4_format_checker` and also `jsonschema.FormatChecker.cls_checks` are deprecated and DeprecationWarning appears every time so these make logs a little dirty and also these attribute/classmethod will be removed in the future. Therefore `jsonschema.draft4_format_checker` should be replaced with `jsonschema.Draft4Validator.FORMAT_CHECKER` and `jsonschema.FormatChecker.cls_checks` should be replaced with `jsonschema.Draft4Validator.FORMAT_CHECKER.checks`. Eventually, DeprecationWarning for jsonschema will disappear with this proposed fix. Closes-Bug: #2008490 Change-Id: I1ef326b8ac17f4bbcbc718d13223da156b0e5ec3
-rw-r--r--tempest/lib/common/jsonschema_validator.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/tempest/lib/common/jsonschema_validator.py b/tempest/lib/common/jsonschema_validator.py
index 1618175c1..5212221c3 100644
--- a/tempest/lib/common/jsonschema_validator.py
+++ b/tempest/lib/common/jsonschema_validator.py
@@ -18,7 +18,7 @@ from oslo_utils import timeutils
# JSON Schema validator and format checker used for JSON Schema validation
JSONSCHEMA_VALIDATOR = jsonschema.Draft4Validator
-FORMAT_CHECKER = jsonschema.draft4_format_checker
+FORMAT_CHECKER = jsonschema.Draft4Validator.FORMAT_CHECKER
# NOTE(gmann): Add customized format checker for 'date-time' format because:
@@ -39,7 +39,7 @@ def _validate_datetime_format(instance):
return True
-@jsonschema.FormatChecker.cls_checks('base64')
+@FORMAT_CHECKER.checks('base64')
def _validate_base64_format(instance):
try:
if isinstance(instance, str):