Update hacking for Python3

The repo is Python 3 now, so update hacking to version 2.0 which
supports Python 3.

Fix problems found.

Change-Id: I81cf5e317bb2f791888e75d87cfd27dfdd2b5f96
This commit is contained in:
Andreas Jaeger 2020-03-28 15:47:38 +01:00
parent de2b8e88b0
commit 5d93b51900
7 changed files with 65 additions and 64 deletions

View File

@ -18,15 +18,15 @@ from magnumclient.common.apiclient.exceptions import * # noqa
# NOTE(akurilin): This alias is left here since v.0.1.3 to support backwards
# compatibility.
InvalidEndpoint = EndpointException
CommunicationError = ConnectionRefused
HTTPBadRequest = BadRequest
HTTPInternalServerError = InternalServerError
HTTPNotFound = NotFound
HTTPServiceUnavailable = ServiceUnavailable
InvalidEndpoint = exceptions.EndpointException
CommunicationError = exceptions.ConnectionRefused
HTTPBadRequest = exceptions.BadRequest
HTTPInternalServerError = exceptions.InternalServerError
HTTPNotFound = exceptions.NotFound
HTTPServiceUnavailable = exceptions.ServiceUnavailable
class AmbiguousAuthSystem(ClientException):
class AmbiguousAuthSystem(exceptions.ClientException):
"""Could not obtain token and endpoint using provided credentials."""
pass
@ -35,7 +35,7 @@ class AmbiguousAuthSystem(ClientException):
AmbigiousAuthSystem = AmbiguousAuthSystem
class InvalidAttribute(ClientException):
class InvalidAttribute(exceptions.ClientException):
pass

View File

@ -33,6 +33,13 @@ from oslo_utils import importutils
from oslo_utils import strutils
import six
from magnumclient.common import cliutils
from magnumclient import exceptions as exc
from magnumclient.i18n import _
from magnumclient.v1 import client as client_v1
from magnumclient.v1 import shell as shell_v1
from magnumclient import version
profiler = importutils.try_import("osprofiler.profiler")
HAS_KEYRING = False
@ -51,12 +58,6 @@ try:
except ImportError:
pass
from magnumclient.common import cliutils
from magnumclient import exceptions as exc
from magnumclient.i18n import _
from magnumclient.v1 import client as client_v1
from magnumclient.v1 import shell as shell_v1
from magnumclient import version
LATEST_API_VERSION = ('1', 'latest')
DEFAULT_INTERFACE = 'public'

View File

@ -123,7 +123,7 @@ class FormatLabelsTest(test_utils.BaseTestCase):
self.assertEqual({}, utils.format_labels(None))
def test_format_labels(self):
l = utils.format_labels([
la = utils.format_labels([
'K1=V1,K2=V2,'
'K3=V3,K4=V4,'
'K5=V5'])
@ -132,10 +132,10 @@ class FormatLabelsTest(test_utils.BaseTestCase):
'K3': 'V3',
'K4': 'V4',
'K5': 'V5'
}, l)
}, la)
def test_format_labels_semicolon(self):
l = utils.format_labels([
la = utils.format_labels([
'K1=V1;K2=V2;'
'K3=V3;K4=V4;'
'K5=V5'])
@ -144,10 +144,10 @@ class FormatLabelsTest(test_utils.BaseTestCase):
'K3': 'V3',
'K4': 'V4',
'K5': 'V5'
}, l)
}, la)
def test_format_labels_mix_commas_semicolon(self):
l = utils.format_labels([
la = utils.format_labels([
'K1=V1,K2=V2,'
'K3=V3;K4=V4,'
'K5=V5'])
@ -156,10 +156,10 @@ class FormatLabelsTest(test_utils.BaseTestCase):
'K3': 'V3',
'K4': 'V4',
'K5': 'V5'
}, l)
}, la)
def test_format_labels_split(self):
l = utils.format_labels([
la = utils.format_labels([
'K1=V1,'
'K2=V22222222222222222222222222222'
'222222222222222222222222222,'
@ -167,10 +167,10 @@ class FormatLabelsTest(test_utils.BaseTestCase):
self.assertEqual({'K1': 'V1',
'K2': 'V22222222222222222222222222222'
'222222222222222222222222222',
'K3': '3.3.3.3'}, l)
'K3': '3.3.3.3'}, la)
def test_format_labels_multiple(self):
l = utils.format_labels([
la = utils.format_labels([
'K1=V1',
'K2=V22222222222222222222222222222'
'222222222222222222222222222',
@ -178,35 +178,35 @@ class FormatLabelsTest(test_utils.BaseTestCase):
self.assertEqual({'K1': 'V1',
'K2': 'V22222222222222222222222222222'
'222222222222222222222222222',
'K3': '3.3.3.3'}, l)
'K3': '3.3.3.3'}, la)
def test_format_labels_multiple_colon_values(self):
l = utils.format_labels([
la = utils.format_labels([
'K1=V1',
'K2=V2,V22,V222,V2222',
'K3=3.3.3.3'])
self.assertEqual({'K1': 'V1',
'K2': 'V2,V22,V222,V2222',
'K3': '3.3.3.3'}, l)
'K3': '3.3.3.3'}, la)
def test_format_labels_parse_comma_false(self):
l = utils.format_labels(
la = utils.format_labels(
['K1=V1,K2=2.2.2.2,K=V'],
parse_comma=False)
self.assertEqual({'K1': 'V1,K2=2.2.2.2,K=V'}, l)
self.assertEqual({'K1': 'V1,K2=2.2.2.2,K=V'}, la)
def test_format_labels_multiple_values_per_labels(self):
l = utils.format_labels([
la = utils.format_labels([
'K1=V1',
'K1=V2'])
self.assertEqual({'K1': 'V1,V2'}, l)
self.assertEqual({'K1': 'V1,V2'}, la)
def test_format_label_special_label(self):
labels = ['K1=V1,K22.2.2.2']
l = utils.format_labels(
la = utils.format_labels(
labels,
parse_comma=True)
self.assertEqual({'K1': 'V1,K22.2.2.2'}, l)
self.assertEqual({'K1': 'V1,K22.2.2.2'}, la)
def test_format_multiple_bad_label(self):
labels = ['K1=V1', 'K22.2.2.2']

View File

@ -95,7 +95,7 @@ class FakeResponse(object):
self.reason = reason
def __getitem__(self, key):
if key is 'location':
if key == 'location':
return 'fake_url'
else:
return None

View File

@ -28,56 +28,56 @@ FAKE_ENV = {'OS_USERNAME': 'username',
class TestCommandLineArgument(utils.TestCase):
_unrecognized_arg_error = [
'.*?^usage: ',
'.*?^error: unrecognized arguments:',
".*?^Try 'magnum help ' for more information.",
r'.*?^usage: ',
r'.*?^error: unrecognized arguments:',
r".*?^Try 'magnum help ' for more information.",
]
_mandatory_group_arg_error = [
'.*?^usage: ',
'.*?^error: one of the arguments',
".*?^Try 'magnum help ",
r'.*?^usage: ',
r'.*?^error: one of the arguments',
r".*?^Try 'magnum help ",
]
_too_many_group_arg_error = [
'.*?^usage: ',
'.*?^error: (argument \-\-[a-z\-]*: not allowed with argument )',
".*?^Try 'magnum help ",
r'.*?^usage: ',
r'.*?^error: (argument \-\-[a-z\-]*: not allowed with argument )',
r".*?^Try 'magnum help ",
]
_mandatory_arg_error = [
'.*?^usage: ',
'.*?^error: (the following arguments|argument)',
".*?^Try 'magnum help ",
]
r'.*?^usage: ',
r'.*?^error: (the following arguments|argument)',
r".*?^Try 'magnum help ",
]
_duplicate_arg_error = [
'.*?^usage: ',
'.*?^error: (Duplicate "<.*>" arguments:)',
".*?^Try 'magnum help ",
]
r'.*?^usage: ',
r'.*?^error: (Duplicate "<.*>" arguments:)',
r".*?^Try 'magnum help ",
]
_deprecated_warning = [
'.*(WARNING: The \-\-[a-z\-]* parameter is deprecated)+',
('.*(Use the [\<\-a-z\-\>]* (positional )*parameter to avoid seeing '
r'.*(WARNING: The \-\-[a-z\-]* parameter is deprecated)+',
(r'.*(Use the [\<\-a-z\-\>]* (positional )*parameter to avoid seeing '
'this message)+')
]
_few_argument_error = [
'.*?^usage: magnum ',
'.*?^error: (the following arguments|too few arguments)',
".*?^Try 'magnum help ",
]
r'.*?^usage: magnum ',
r'.*?^error: (the following arguments|too few arguments)',
r".*?^Try 'magnum help ",
]
_invalid_value_error = [
'.*?^usage: ',
'.*?^error: argument .*: invalid .* value:',
".*?^Try 'magnum help ",
]
r'.*?^usage: ',
r'.*?^error: argument .*: invalid .* value:',
r".*?^Try 'magnum help ",
]
_bay_status_error = [
'.*?^Bay status for',
]
r'.*?^Bay status for',
]
def setUp(self):
super(TestCommandLineArgument, self).setUp()

View File

@ -1,7 +1,7 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
hacking>=2.0,<2.1 # Apache-2.0
bandit!=1.6.0,>=1.1.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD

View File

@ -69,7 +69,7 @@ commands =
# E123, E125 skipped as they are invalid PEP-8.
show-source = True
ignore = E123,E125
ignore = E123,E125,W503,W504
builtins = _
exclude=.venv,.git,.tox,dist,doc,,*lib/python*,*egg,build