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
This commit is contained in:
Andreas Jaeger 2020-04-29 22:29:01 +02:00
parent 7c6389094c
commit d3d4670906
2 changed files with 7 additions and 2 deletions

View File

@ -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()

View File

@ -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):