From d90726a1eb1058d88f328b063e5d062198f9ca0c Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Thu, 2 Apr 2020 15:08:30 +0200 Subject: [PATCH] Update hacking for Python3 The repo is Python 3 now, so update hacking to version 3.0 which supports Python 3. Fix problems found. Remove hacking and friends from lower-constraints, they are not needed for installation. Change-Id: I3f23bf09ef24fe34e128102c34382da98e10f5c1 --- lower-constraints.txt | 4 ---- oslo_utils/imageutils.py | 2 +- oslo_utils/secretutils.py | 1 + oslo_utils/tests/test_imageutils.py | 2 ++ oslo_utils/tests/test_strutils.py | 1 + test-requirements.txt | 2 +- tools/perf_test_mask_password.py | 2 +- tox.ini | 3 ++- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index c27fe462..57f27691 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -7,11 +7,9 @@ debtcollector==1.2.0 eventlet==0.18.2 extras==1.0.0 fixtures==3.0.0 -flake8==2.5.5 funcsigs==1.0.0 gitdb==0.6.4 GitPython==1.0.1 -hacking==0.12.0 iso8601==0.1.11 keystoneauth1==3.4.0 linecache2==1.0.0 @@ -24,8 +22,6 @@ oslo.config==5.2.0 oslo.i18n==3.15.3 oslotest==3.2.0 pbr==2.0.0 -pep8==1.5.7 -pyflakes==0.8.1 pyparsing==2.1.0 python-mimeparse==1.6.0 python-subunit==1.0.0 diff --git a/oslo_utils/imageutils.py b/oslo_utils/imageutils.py index 82ea29d5..fc7b494d 100644 --- a/oslo_utils/imageutils.py +++ b/oslo_utils/imageutils.py @@ -45,7 +45,7 @@ class QemuImgInfo(object): r"\s+(.*?)\)\s*$"), re.I) TOP_LEVEL_RE = re.compile(r"^([\w\d\s\_\-]+):(.*)$") SIZE_RE = re.compile(r"([0-9]+[eE][-+][0-9]+|\d*\.?\d+)" - "\s*(\w+)?(\s*\(\s*(\d+)\s+bytes\s*\))?", + r"\s*(\w+)?(\s*\(\s*(\d+)\s+bytes\s*\))?", re.I) def __init__(self, cmd_output=None, format='human'): diff --git a/oslo_utils/secretutils.py b/oslo_utils/secretutils.py index 963c6341..ad350d2f 100644 --- a/oslo_utils/secretutils.py +++ b/oslo_utils/secretutils.py @@ -39,6 +39,7 @@ def _constant_time_compare(first, second): result |= ord(x) ^ ord(y) return result == 0 + try: constant_time_compare = hmac.compare_digest except AttributeError: diff --git a/oslo_utils/tests/test_imageutils.py b/oslo_utils/tests/test_imageutils.py index 3a6bfec1..6b3a9faa 100644 --- a/oslo_utils/tests/test_imageutils.py +++ b/oslo_utils/tests/test_imageutils.py @@ -137,6 +137,7 @@ class ImageUtilsRawTestCase(test_base.BaseTestCase): image_info = imageutils.QemuImgInfo(example_output) self._base_validation(image_info) + ImageUtilsRawTestCase.generate_scenarios() @@ -203,6 +204,7 @@ class ImageUtilsQemuTestCase(ImageUtilsRawTestCase): if self.encrypted is not None: self.assertEqual(image_info.encrypted, self.encrypted) + ImageUtilsQemuTestCase.generate_scenarios() diff --git a/oslo_utils/tests/test_strutils.py b/oslo_utils/tests/test_strutils.py index 25e974c9..a63ef23a 100644 --- a/oslo_utils/tests/test_strutils.py +++ b/oslo_utils/tests/test_strutils.py @@ -291,6 +291,7 @@ class StringToBytesTest(test_base.BaseTestCase): else: self.assertAlmostEqual(actual, expected) + StringToBytesTest.generate_scenarios() diff --git a/test-requirements.txt b/test-requirements.txt index ce63b708..ff549ff6 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,7 +2,7 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking>=1.1.0,<1.2.0 # Apache-2.0 +hacking>=3.0,<3.1.0 # Apache-2.0 eventlet>=0.18.2,!=0.18.3,!=0.20.1,!=0.21.0,!=0.23.0 # MIT fixtures>=3.0.0 # Apache-2.0/BSD diff --git a/tools/perf_test_mask_password.py b/tools/perf_test_mask_password.py index f69a734d..e470766a 100644 --- a/tools/perf_test_mask_password.py +++ b/tools/perf_test_mask_password.py @@ -37,7 +37,7 @@ print('payload has %d bytes' % len(input_str)) for pattern in strutils._SANITIZE_PATTERNS_2['admin_pass']: print('\ntesting %s' % pattern.pattern) t = timeit.Timer( - "re.sub(pattern, r'\g<1>***\g<2>', payload)", + r"re.sub(pattern, r'\g<1>***\g<2>', payload)", """ import re payload = '''%s''' diff --git a/tox.ini b/tox.ini index abffbe15..7297a5ae 100644 --- a/tox.ini +++ b/tox.ini @@ -37,7 +37,8 @@ commands = bandit -r oslo_utils -x tests -n5 [flake8] # E731 skipped as assign a lambda expression -ignore = E123,E731,H405 +# W504 line break after binary operator +ignore = E123,E731,H405,W504 show-source = True exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,__init__.py