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:
parent
de2b8e88b0
commit
5d93b51900
@ -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
|
# NOTE(akurilin): This alias is left here since v.0.1.3 to support backwards
|
||||||
# compatibility.
|
# compatibility.
|
||||||
InvalidEndpoint = EndpointException
|
InvalidEndpoint = exceptions.EndpointException
|
||||||
CommunicationError = ConnectionRefused
|
CommunicationError = exceptions.ConnectionRefused
|
||||||
HTTPBadRequest = BadRequest
|
HTTPBadRequest = exceptions.BadRequest
|
||||||
HTTPInternalServerError = InternalServerError
|
HTTPInternalServerError = exceptions.InternalServerError
|
||||||
HTTPNotFound = NotFound
|
HTTPNotFound = exceptions.NotFound
|
||||||
HTTPServiceUnavailable = ServiceUnavailable
|
HTTPServiceUnavailable = exceptions.ServiceUnavailable
|
||||||
|
|
||||||
|
|
||||||
class AmbiguousAuthSystem(ClientException):
|
class AmbiguousAuthSystem(exceptions.ClientException):
|
||||||
"""Could not obtain token and endpoint using provided credentials."""
|
"""Could not obtain token and endpoint using provided credentials."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ class AmbiguousAuthSystem(ClientException):
|
|||||||
AmbigiousAuthSystem = AmbiguousAuthSystem
|
AmbigiousAuthSystem = AmbiguousAuthSystem
|
||||||
|
|
||||||
|
|
||||||
class InvalidAttribute(ClientException):
|
class InvalidAttribute(exceptions.ClientException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,6 +33,13 @@ from oslo_utils import importutils
|
|||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
import six
|
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")
|
profiler = importutils.try_import("osprofiler.profiler")
|
||||||
|
|
||||||
HAS_KEYRING = False
|
HAS_KEYRING = False
|
||||||
@ -51,12 +58,6 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
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')
|
LATEST_API_VERSION = ('1', 'latest')
|
||||||
DEFAULT_INTERFACE = 'public'
|
DEFAULT_INTERFACE = 'public'
|
||||||
|
@ -123,7 +123,7 @@ class FormatLabelsTest(test_utils.BaseTestCase):
|
|||||||
self.assertEqual({}, utils.format_labels(None))
|
self.assertEqual({}, utils.format_labels(None))
|
||||||
|
|
||||||
def test_format_labels(self):
|
def test_format_labels(self):
|
||||||
l = utils.format_labels([
|
la = utils.format_labels([
|
||||||
'K1=V1,K2=V2,'
|
'K1=V1,K2=V2,'
|
||||||
'K3=V3,K4=V4,'
|
'K3=V3,K4=V4,'
|
||||||
'K5=V5'])
|
'K5=V5'])
|
||||||
@ -132,10 +132,10 @@ class FormatLabelsTest(test_utils.BaseTestCase):
|
|||||||
'K3': 'V3',
|
'K3': 'V3',
|
||||||
'K4': 'V4',
|
'K4': 'V4',
|
||||||
'K5': 'V5'
|
'K5': 'V5'
|
||||||
}, l)
|
}, la)
|
||||||
|
|
||||||
def test_format_labels_semicolon(self):
|
def test_format_labels_semicolon(self):
|
||||||
l = utils.format_labels([
|
la = utils.format_labels([
|
||||||
'K1=V1;K2=V2;'
|
'K1=V1;K2=V2;'
|
||||||
'K3=V3;K4=V4;'
|
'K3=V3;K4=V4;'
|
||||||
'K5=V5'])
|
'K5=V5'])
|
||||||
@ -144,10 +144,10 @@ class FormatLabelsTest(test_utils.BaseTestCase):
|
|||||||
'K3': 'V3',
|
'K3': 'V3',
|
||||||
'K4': 'V4',
|
'K4': 'V4',
|
||||||
'K5': 'V5'
|
'K5': 'V5'
|
||||||
}, l)
|
}, la)
|
||||||
|
|
||||||
def test_format_labels_mix_commas_semicolon(self):
|
def test_format_labels_mix_commas_semicolon(self):
|
||||||
l = utils.format_labels([
|
la = utils.format_labels([
|
||||||
'K1=V1,K2=V2,'
|
'K1=V1,K2=V2,'
|
||||||
'K3=V3;K4=V4,'
|
'K3=V3;K4=V4,'
|
||||||
'K5=V5'])
|
'K5=V5'])
|
||||||
@ -156,10 +156,10 @@ class FormatLabelsTest(test_utils.BaseTestCase):
|
|||||||
'K3': 'V3',
|
'K3': 'V3',
|
||||||
'K4': 'V4',
|
'K4': 'V4',
|
||||||
'K5': 'V5'
|
'K5': 'V5'
|
||||||
}, l)
|
}, la)
|
||||||
|
|
||||||
def test_format_labels_split(self):
|
def test_format_labels_split(self):
|
||||||
l = utils.format_labels([
|
la = utils.format_labels([
|
||||||
'K1=V1,'
|
'K1=V1,'
|
||||||
'K2=V22222222222222222222222222222'
|
'K2=V22222222222222222222222222222'
|
||||||
'222222222222222222222222222,'
|
'222222222222222222222222222,'
|
||||||
@ -167,10 +167,10 @@ class FormatLabelsTest(test_utils.BaseTestCase):
|
|||||||
self.assertEqual({'K1': 'V1',
|
self.assertEqual({'K1': 'V1',
|
||||||
'K2': 'V22222222222222222222222222222'
|
'K2': 'V22222222222222222222222222222'
|
||||||
'222222222222222222222222222',
|
'222222222222222222222222222',
|
||||||
'K3': '3.3.3.3'}, l)
|
'K3': '3.3.3.3'}, la)
|
||||||
|
|
||||||
def test_format_labels_multiple(self):
|
def test_format_labels_multiple(self):
|
||||||
l = utils.format_labels([
|
la = utils.format_labels([
|
||||||
'K1=V1',
|
'K1=V1',
|
||||||
'K2=V22222222222222222222222222222'
|
'K2=V22222222222222222222222222222'
|
||||||
'222222222222222222222222222',
|
'222222222222222222222222222',
|
||||||
@ -178,35 +178,35 @@ class FormatLabelsTest(test_utils.BaseTestCase):
|
|||||||
self.assertEqual({'K1': 'V1',
|
self.assertEqual({'K1': 'V1',
|
||||||
'K2': 'V22222222222222222222222222222'
|
'K2': 'V22222222222222222222222222222'
|
||||||
'222222222222222222222222222',
|
'222222222222222222222222222',
|
||||||
'K3': '3.3.3.3'}, l)
|
'K3': '3.3.3.3'}, la)
|
||||||
|
|
||||||
def test_format_labels_multiple_colon_values(self):
|
def test_format_labels_multiple_colon_values(self):
|
||||||
l = utils.format_labels([
|
la = utils.format_labels([
|
||||||
'K1=V1',
|
'K1=V1',
|
||||||
'K2=V2,V22,V222,V2222',
|
'K2=V2,V22,V222,V2222',
|
||||||
'K3=3.3.3.3'])
|
'K3=3.3.3.3'])
|
||||||
self.assertEqual({'K1': 'V1',
|
self.assertEqual({'K1': 'V1',
|
||||||
'K2': 'V2,V22,V222,V2222',
|
'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):
|
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'],
|
['K1=V1,K2=2.2.2.2,K=V'],
|
||||||
parse_comma=False)
|
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):
|
def test_format_labels_multiple_values_per_labels(self):
|
||||||
l = utils.format_labels([
|
la = utils.format_labels([
|
||||||
'K1=V1',
|
'K1=V1',
|
||||||
'K1=V2'])
|
'K1=V2'])
|
||||||
self.assertEqual({'K1': 'V1,V2'}, l)
|
self.assertEqual({'K1': 'V1,V2'}, la)
|
||||||
|
|
||||||
def test_format_label_special_label(self):
|
def test_format_label_special_label(self):
|
||||||
labels = ['K1=V1,K22.2.2.2']
|
labels = ['K1=V1,K22.2.2.2']
|
||||||
l = utils.format_labels(
|
la = utils.format_labels(
|
||||||
labels,
|
labels,
|
||||||
parse_comma=True)
|
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):
|
def test_format_multiple_bad_label(self):
|
||||||
labels = ['K1=V1', 'K22.2.2.2']
|
labels = ['K1=V1', 'K22.2.2.2']
|
||||||
|
@ -95,7 +95,7 @@ class FakeResponse(object):
|
|||||||
self.reason = reason
|
self.reason = reason
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
if key is 'location':
|
if key == 'location':
|
||||||
return 'fake_url'
|
return 'fake_url'
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
@ -28,56 +28,56 @@ FAKE_ENV = {'OS_USERNAME': 'username',
|
|||||||
|
|
||||||
class TestCommandLineArgument(utils.TestCase):
|
class TestCommandLineArgument(utils.TestCase):
|
||||||
_unrecognized_arg_error = [
|
_unrecognized_arg_error = [
|
||||||
'.*?^usage: ',
|
r'.*?^usage: ',
|
||||||
'.*?^error: unrecognized arguments:',
|
r'.*?^error: unrecognized arguments:',
|
||||||
".*?^Try 'magnum help ' for more information.",
|
r".*?^Try 'magnum help ' for more information.",
|
||||||
]
|
]
|
||||||
|
|
||||||
_mandatory_group_arg_error = [
|
_mandatory_group_arg_error = [
|
||||||
'.*?^usage: ',
|
r'.*?^usage: ',
|
||||||
'.*?^error: one of the arguments',
|
r'.*?^error: one of the arguments',
|
||||||
".*?^Try 'magnum help ",
|
r".*?^Try 'magnum help ",
|
||||||
]
|
]
|
||||||
|
|
||||||
_too_many_group_arg_error = [
|
_too_many_group_arg_error = [
|
||||||
'.*?^usage: ',
|
r'.*?^usage: ',
|
||||||
'.*?^error: (argument \-\-[a-z\-]*: not allowed with argument )',
|
r'.*?^error: (argument \-\-[a-z\-]*: not allowed with argument )',
|
||||||
".*?^Try 'magnum help ",
|
r".*?^Try 'magnum help ",
|
||||||
]
|
]
|
||||||
|
|
||||||
_mandatory_arg_error = [
|
_mandatory_arg_error = [
|
||||||
'.*?^usage: ',
|
r'.*?^usage: ',
|
||||||
'.*?^error: (the following arguments|argument)',
|
r'.*?^error: (the following arguments|argument)',
|
||||||
".*?^Try 'magnum help ",
|
r".*?^Try 'magnum help ",
|
||||||
]
|
]
|
||||||
|
|
||||||
_duplicate_arg_error = [
|
_duplicate_arg_error = [
|
||||||
'.*?^usage: ',
|
r'.*?^usage: ',
|
||||||
'.*?^error: (Duplicate "<.*>" arguments:)',
|
r'.*?^error: (Duplicate "<.*>" arguments:)',
|
||||||
".*?^Try 'magnum help ",
|
r".*?^Try 'magnum help ",
|
||||||
]
|
]
|
||||||
|
|
||||||
_deprecated_warning = [
|
_deprecated_warning = [
|
||||||
'.*(WARNING: The \-\-[a-z\-]* parameter is deprecated)+',
|
r'.*(WARNING: The \-\-[a-z\-]* parameter is deprecated)+',
|
||||||
('.*(Use the [\<\-a-z\-\>]* (positional )*parameter to avoid seeing '
|
(r'.*(Use the [\<\-a-z\-\>]* (positional )*parameter to avoid seeing '
|
||||||
'this message)+')
|
'this message)+')
|
||||||
]
|
]
|
||||||
|
|
||||||
_few_argument_error = [
|
_few_argument_error = [
|
||||||
'.*?^usage: magnum ',
|
r'.*?^usage: magnum ',
|
||||||
'.*?^error: (the following arguments|too few arguments)',
|
r'.*?^error: (the following arguments|too few arguments)',
|
||||||
".*?^Try 'magnum help ",
|
r".*?^Try 'magnum help ",
|
||||||
]
|
]
|
||||||
|
|
||||||
_invalid_value_error = [
|
_invalid_value_error = [
|
||||||
'.*?^usage: ',
|
r'.*?^usage: ',
|
||||||
'.*?^error: argument .*: invalid .* value:',
|
r'.*?^error: argument .*: invalid .* value:',
|
||||||
".*?^Try 'magnum help ",
|
r".*?^Try 'magnum help ",
|
||||||
]
|
]
|
||||||
|
|
||||||
_bay_status_error = [
|
_bay_status_error = [
|
||||||
'.*?^Bay status for',
|
r'.*?^Bay status for',
|
||||||
]
|
]
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestCommandLineArgument, self).setUp()
|
super(TestCommandLineArgument, self).setUp()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# The order of packages is significant, because pip processes them in the order
|
# 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
|
# of appearance. Changing the order has an impact on the overall integration
|
||||||
# process, which may cause wedges in the gate later.
|
# 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
|
bandit!=1.6.0,>=1.1.0 # Apache-2.0
|
||||||
coverage!=4.4,>=4.0 # Apache-2.0
|
coverage!=4.4,>=4.0 # Apache-2.0
|
||||||
fixtures>=3.0.0 # Apache-2.0/BSD
|
fixtures>=3.0.0 # Apache-2.0/BSD
|
||||||
|
2
tox.ini
2
tox.ini
@ -69,7 +69,7 @@ commands =
|
|||||||
# E123, E125 skipped as they are invalid PEP-8.
|
# E123, E125 skipped as they are invalid PEP-8.
|
||||||
|
|
||||||
show-source = True
|
show-source = True
|
||||||
ignore = E123,E125
|
ignore = E123,E125,W503,W504
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude=.venv,.git,.tox,dist,doc,,*lib/python*,*egg,build
|
exclude=.venv,.git,.tox,dist,doc,,*lib/python*,*egg,build
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user