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: I5ae47a7b11ff29a301e440c15daf30db7738485b
changes/09/717009/1
Andreas Jaeger 3 years ago
parent 6b5a163022
commit 82da2378ea

@ -177,7 +177,7 @@ class HTTPClient(_BaseHTTPClient):
if kwargs.get('insecure', False) is True:
self.session.verify = False
else:
if kwargs.get('cacert', None) is not '':
if kwargs.get('cacert', None) != '':
self.session.verify = kwargs.get('cacert', True)
self.session.cert = (kwargs.get('cert_file'),

@ -52,7 +52,7 @@ class SimpleReadOnlyGlanceClientTest(base.ClientTestBase):
commands = []
cmds_start = lines.index('Positional arguments:')
cmds_end = lines.index('Optional arguments:')
command_pattern = re.compile('^ {4}([a-z0-9\-\_]+)')
command_pattern = re.compile(r'^ {4}([a-z0-9\-\_]+)')
for line in lines[cmds_start:cmds_end]:
match = command_pattern.match(line)
if match:

@ -72,7 +72,7 @@ class SimpleReadOnlyGlanceClientTest(base.ClientTestBase):
commands = []
cmds_start = lines.index('Positional arguments:')
cmds_end = lines.index('Optional arguments:')
command_pattern = re.compile('^ {4}([a-z0-9\-\_]+)')
command_pattern = re.compile(r'^ {4}([a-z0-9\-\_]+)')
for line in lines[cmds_start:cmds_end]:
match = command_pattern.match(line)
if match:

@ -367,11 +367,11 @@ class TestClient(testtools.TestCase):
self.assertTrue(mock_log.called, 'LOG.debug never called')
self.assertTrue(mock_log.call_args[0],
'LOG.debug called with no arguments')
hd_regex = ".*\s-H\s+'\s*%s\s*:\s*%s\s*'.*" % (hd_name, hd_val)
hd_regex = r".*\s-H\s+'\s*%s\s*:\s*%s\s*'.*" % (hd_name, hd_val)
self.assertThat(mock_log.call_args[0][0],
matchers.MatchesRegex(hd_regex),
'header not found in curl command')
body_regex = ".*\s-d\s+'%s'\s.*" % body
body_regex = r".*\s-d\s+'%s'\s.*" % body
self.assertThat(mock_log.call_args[0][0],
matchers.MatchesRegex(body_regex),
'body not found in curl command')
@ -390,12 +390,12 @@ class TestClient(testtools.TestCase):
needles = {'key': key, 'cert': cert, 'cacert': cacert}
for option, value in needles.items():
if value:
regex = ".*\s--%s\s+('%s'|%s).*" % (option, value, value)
regex = r".*\s--%s\s+('%s'|%s).*" % (option, value, value)
self.assertThat(mock_log.call_args[0][0],
matchers.MatchesRegex(regex),
'no --%s option in curl command' % option)
else:
regex = ".*\s--%s\s+.*" % option
regex = r".*\s--%s\s+.*" % option
self.assertThat(mock_log.call_args[0][0],
matchers.Not(matchers.MatchesRegex(regex)),
'unexpected --%s option in curl command' %
@ -421,7 +421,7 @@ class TestClient(testtools.TestCase):
self.assertTrue(mock_log.call_args[0],
'LOG.debug called with no arguments')
self.assertThat(mock_log.call_args[0][0],
matchers.MatchesRegex('.*\s-k\s.*'),
matchers.MatchesRegex(r'.*\s-k\s.*'),
'no -k option in curl command')
@mock.patch('glanceclient.common.http.LOG.debug')

@ -58,6 +58,7 @@ def _get_namespace_fixture(ns_name, rt_name=RESOURCE_TYPE1, **kwargs):
return ns
data_fixtures = {
"/v2/metadefs/namespaces?limit=20": {
"GET": (

@ -58,6 +58,7 @@ def _get_object_fixture(ns_name, obj_name, **kwargs):
return obj
data_fixtures = {
"/v2/metadefs/namespaces/%s/objects" % NAMESPACE1: {
"GET": (

@ -55,6 +55,8 @@ def schema_args(schema_getter, omit=None):
'locations': {'type': 'string'},
'copy_from': {'type': 'string'}}}
return original_schema_args(my_schema_getter, omit)
utils.schema_args = schema_args
from glanceclient.v2 import shell as test_shell # noqa

@ -840,15 +840,15 @@ def do_image_reactivate(gc, args):
@utils.arg('tag_value', metavar='<TAG_VALUE>',
help=_('Value of the tag.'))
def do_image_tag_update(gc, args):
"""Update an image with the given tag."""
if not (args.image_id and args.tag_value):
utils.exit('Unable to update tag. Specify image_id and tag_value')
else:
gc.image_tags.update(args.image_id, args.tag_value)
image = gc.images.get(args.image_id)
image = [image]
columns = ['ID', 'Tags']
utils.print_list(image, columns)
"""Update an image with the given tag."""
if not (args.image_id and args.tag_value):
utils.exit('Unable to update tag. Specify image_id and tag_value')
else:
gc.image_tags.update(args.image_id, args.tag_value)
image = gc.images.get(args.image_id)
image = [image]
columns = ['ID', 'Tags']
utils.print_list(image, columns)
@utils.arg('image_id', metavar='<IMAGE_ID>',

@ -13,9 +13,7 @@ dulwich==0.15.0
extras==1.0.0
fasteners==0.7.0
fixtures==3.0.0
flake8==2.5.5
future==0.16.0
hacking==0.12.0
idna==2.6
imagesize==0.7.1
iso8601==0.1.11
@ -45,11 +43,9 @@ oslo.serialization==2.18.0
oslo.utils==3.33.0
paramiko==2.0.0
pbr==2.0.0
pep8==1.5.7
prettytable==0.7.1
pyasn1==0.1.8
pycparser==2.18
pyflakes==0.8.1
Pygments==2.2.0
pyinotify==0.9.6
pyOpenSSL==17.1.0

@ -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
coverage!=4.4,>=4.0 # Apache-2.0
mock>=2.0.0 # BSD

@ -63,7 +63,8 @@ commands =
[flake8]
# E731 skipped as assign a lambda expression
ignore = E731,F403,F812,F821
# W504 line break after binary operator
ignore = E731,F403,F812,F821,W504
show-source = True
exclude = .venv*,.tox,dist,*egg,build,.git,doc,*lib/python*,.update-venv

Loading…
Cancel
Save