From eb68d6c3f39291fccc8001a2f37312c37e4d342a Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Wed, 20 Nov 2024 12:08:01 +0900 Subject: [PATCH] Replace deprecated FormatChecker.cls_checks The method was deprecated in jsonschema 4.14.0[1] and now triggers the following warning. DeprecationWarning: FormatChecker.cls_checks is deprecated. Call FormatChecker.checks on a specific FormatChecker instance instead. [1] https://github.com/python-jsonschema/jsonschema/commit/cd8f0592b93947a9deb8b3e6502cc5a69cb6d722 Also resolve the following warning at the same time. DeprecationWarning: Accessing jsonschema.draft4_format_checker is deprecated and will be removed in a future release. Instead, use the FORMAT_CHECKER attribute on the corresponding Validator. Closes-Bug: #2089051 Related-Bug: #2008490 Change-Id: I0060e36d0be51cbafca5fef39c11178d2521f23a Signed-off-by: Takashi Kajinami --- requirements.txt | 2 +- tempest/lib/common/jsonschema_validator.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index a1eff53d99..eafbe0aa00 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0 cliff!=2.9.0,>=2.8.0 # Apache-2.0 -jsonschema>=3.2.0 # MIT +jsonschema>=4.5.0 # MIT testtools>=2.2.0 # MIT paramiko>=2.7.0 # LGPLv2.1+ cryptography>=2.1 # BSD/Apache-2.0 diff --git a/tempest/lib/common/jsonschema_validator.py b/tempest/lib/common/jsonschema_validator.py index 1618175c1c..e56a81f3a9 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_VALIDATOR.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):