From d3d4670906d8493492affc801d46b716c8949b79 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Wed, 29 Apr 2020 22:29:01 +0200 Subject: [PATCH] Fix py38 failures The py38 and py36 give different values looking at source code for one hacking test, handle both cases. Fix dictionary changed during iteration error in validators.py with creating a temporary list so that the dictionary can be manipulated. Change-Id: I70f2df5a80115f6e739cf97812fbe1a2352abd28 --- barbican/common/validators.py | 2 +- barbican/tests/test_hacking.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/barbican/common/validators.py b/barbican/common/validators.py index 9264d8d2b..7984b9c49 100644 --- a/barbican/common/validators.py +++ b/barbican/common/validators.py @@ -345,7 +345,7 @@ class NewSecretMetadataValidator(ValidatorBase): """Extracts and returns the metadata from the JSON data.""" metadata = json_data['metadata'] - for key in metadata: + for key in list(metadata): # make sure key is a string and url-safe. if not isinstance(key, six.string_types): raise exception.InvalidMetadataRequest() diff --git a/barbican/tests/test_hacking.py b/barbican/tests/test_hacking.py index 2b73e1e44..1434bebb8 100644 --- a/barbican/tests/test_hacking.py +++ b/barbican/tests/test_hacking.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +import sys import textwrap from unittest import mock @@ -100,8 +101,12 @@ class HackingTestCase(utils.BaseTestCase): LOG.{0}("Volume %s caught fire and is at %d degrees C and " "climbing.", ('volume1', 500)) """ + if (sys.version_info >= (3, 8)): + exc_errors = [(4, 20, 'B310')] + else: + exc_errors = [(4, 21, 'B310')] self._assert_has_errors(code.format(log_method), checker, - expected_errors=[(4, 21, 'B310')]) + expected_errors=exc_errors) def test_str_on_exception(self):