diff --git a/magnumclient/exceptions.py b/magnumclient/exceptions.py index d069f858..8afd80a0 100644 --- a/magnumclient/exceptions.py +++ b/magnumclient/exceptions.py @@ -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 diff --git a/magnumclient/shell.py b/magnumclient/shell.py index 259f1ad0..9da92558 100644 --- a/magnumclient/shell.py +++ b/magnumclient/shell.py @@ -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' diff --git a/magnumclient/tests/test_utils.py b/magnumclient/tests/test_utils.py index 4117eed0..831fea4f 100644 --- a/magnumclient/tests/test_utils.py +++ b/magnumclient/tests/test_utils.py @@ -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'] diff --git a/magnumclient/tests/utils.py b/magnumclient/tests/utils.py index 8b6a4a4b..15626715 100644 --- a/magnumclient/tests/utils.py +++ b/magnumclient/tests/utils.py @@ -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 diff --git a/magnumclient/tests/v1/shell_test_base.py b/magnumclient/tests/v1/shell_test_base.py index 89f6195c..b165298b 100644 --- a/magnumclient/tests/v1/shell_test_base.py +++ b/magnumclient/tests/v1/shell_test_base.py @@ -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() diff --git a/test-requirements.txt b/test-requirements.txt index 49dfa5cd..fd61dfad 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -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 diff --git a/tox.ini b/tox.ini index 44d8d60c..1f2f1329 100644 --- a/tox.ini +++ b/tox.ini @@ -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