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: Id80f3fed3c693cefedca2d6468ab48577ccd9999
This commit is contained in:
parent
3c40b5c093
commit
f4d3638d38
@ -6,7 +6,7 @@ bandit>=1.1.0 # Apache-2.0
|
||||
coverage!=4.4,>=4.0 # Apache-2.0
|
||||
doc8>=0.6.0 # Apache-2.0
|
||||
ddt>=1.0.1 # MIT
|
||||
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
|
||||
hacking>=2.0,<2.1 # Apache-2.0
|
||||
oslotest>=3.2.0 # Apache-2.0
|
||||
osprofiler>=1.4.0 # Apache-2.0
|
||||
stestr>=2.0.0
|
||||
|
2
tox.ini
2
tox.ini
@ -89,7 +89,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
|
||||
|
||||
|
@ -36,6 +36,8 @@ def _construct_yaml_str(self, node):
|
||||
# Override the default string handling function
|
||||
# to always return unicode objects
|
||||
return self.construct_scalar(node)
|
||||
|
||||
|
||||
yaml_loader.add_constructor(u'tag:yaml.org,2002:str', _construct_yaml_str)
|
||||
# Unquoted dates like 2013-05-23 in yaml files get loaded as objects of type
|
||||
# datetime.data which causes problems in API layer when being processed by
|
||||
|
@ -324,8 +324,8 @@ def parse_health(hc_str):
|
||||
|
||||
|
||||
def _convert_healthcheck_para(time, err_msg):
|
||||
int_pattern = '^\d+$'
|
||||
time_pattern = '^\d+(s|m|h)$'
|
||||
int_pattern = r'^\d+$'
|
||||
time_pattern = r'^\d+(s|m|h)$'
|
||||
ret = 0
|
||||
if re.match(int_pattern, time):
|
||||
ret = int(time)
|
||||
|
@ -17,24 +17,25 @@ from zunclient.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
|
||||
CommandErrorException = CommandError
|
||||
InvalidEndpoint = exceptions.EndpointException
|
||||
CommunicationError = exceptions.ConnectionRefused
|
||||
HTTPBadRequest = exceptions.BadRequest
|
||||
HTTPInternalServerError = exceptions.InternalServerError
|
||||
HTTPNotFound = exceptions.NotFound
|
||||
HTTPServiceUnavailable = exceptions.ServiceUnavailable
|
||||
CommandErrorException = exceptions.CommandError
|
||||
|
||||
|
||||
class AmbiguousAuthSystem(ClientException):
|
||||
class AmbiguousAuthSystem(exceptions.ClientException):
|
||||
"""Could not obtain token and endpoint using provided credentials."""
|
||||
pass
|
||||
|
||||
|
||||
# Alias for backwards compatibility
|
||||
AmbigiousAuthSystem = AmbiguousAuthSystem
|
||||
|
||||
|
||||
class InvalidAttribute(ClientException):
|
||||
class InvalidAttribute(exceptions.ClientException):
|
||||
pass
|
||||
|
||||
|
||||
|
@ -34,6 +34,16 @@ from oslo_utils import importutils
|
||||
from oslo_utils import strutils
|
||||
import six
|
||||
|
||||
from zunclient import api_versions
|
||||
from zunclient import client as base_client
|
||||
from zunclient.common.apiclient import auth
|
||||
from zunclient.common import cliutils
|
||||
from zunclient import exceptions as exc
|
||||
from zunclient.i18n import _
|
||||
from zunclient.v1 import shell as shell_v1
|
||||
from zunclient import version
|
||||
|
||||
|
||||
profiler = importutils.try_import("osprofiler.profiler")
|
||||
|
||||
HAS_KEYRING = False
|
||||
@ -52,15 +62,6 @@ try:
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
from zunclient import api_versions
|
||||
from zunclient import client as base_client
|
||||
from zunclient.common.apiclient import auth
|
||||
from zunclient.common import cliutils
|
||||
from zunclient import exceptions as exc
|
||||
from zunclient.i18n import _
|
||||
from zunclient.v1 import shell as shell_v1
|
||||
from zunclient import version
|
||||
|
||||
DEFAULT_API_VERSION = api_versions.DEFAULT_API_VERSION
|
||||
DEFAULT_ENDPOINT_TYPE = 'publicURL'
|
||||
DEFAULT_SERVICE_TYPE = 'container'
|
||||
|
@ -89,7 +89,7 @@ class FormatArgsTest(test_utils.BaseTestCase):
|
||||
self.assertEqual({}, utils.format_args(None))
|
||||
|
||||
def test_format_args(self):
|
||||
l = utils.format_args([
|
||||
li = utils.format_args([
|
||||
'K1=V1,K2=V2,'
|
||||
'K3=V3,K4=V4,'
|
||||
'K5=V5'])
|
||||
@ -98,10 +98,10 @@ class FormatArgsTest(test_utils.BaseTestCase):
|
||||
'K3': 'V3',
|
||||
'K4': 'V4',
|
||||
'K5': 'V5'
|
||||
}, l)
|
||||
}, li)
|
||||
|
||||
def test_format_args_semicolon(self):
|
||||
l = utils.format_args([
|
||||
li = utils.format_args([
|
||||
'K1=V1;K2=V2;'
|
||||
'K3=V3;K4=V4;'
|
||||
'K5=V5'])
|
||||
@ -110,10 +110,10 @@ class FormatArgsTest(test_utils.BaseTestCase):
|
||||
'K3': 'V3',
|
||||
'K4': 'V4',
|
||||
'K5': 'V5'
|
||||
}, l)
|
||||
}, li)
|
||||
|
||||
def test_format_args_mix_commas_semicolon(self):
|
||||
l = utils.format_args([
|
||||
li = utils.format_args([
|
||||
'K1=V1,K2=V2,'
|
||||
'K3=V3;K4=V4,'
|
||||
'K5=V5'])
|
||||
@ -122,10 +122,10 @@ class FormatArgsTest(test_utils.BaseTestCase):
|
||||
'K3': 'V3',
|
||||
'K4': 'V4',
|
||||
'K5': 'V5'
|
||||
}, l)
|
||||
}, li)
|
||||
|
||||
def test_format_args_split(self):
|
||||
l = utils.format_args([
|
||||
li = utils.format_args([
|
||||
'K1=V1,'
|
||||
'K2=V22222222222222222222222222222'
|
||||
'222222222222222222222222222,'
|
||||
@ -133,10 +133,10 @@ class FormatArgsTest(test_utils.BaseTestCase):
|
||||
self.assertEqual({'K1': 'V1',
|
||||
'K2': 'V22222222222222222222222222222'
|
||||
'222222222222222222222222222',
|
||||
'K3': '3.3.3.3'}, l)
|
||||
'K3': '3.3.3.3'}, li)
|
||||
|
||||
def test_format_args_multiple(self):
|
||||
l = utils.format_args([
|
||||
li = utils.format_args([
|
||||
'K1=V1',
|
||||
'K2=V22222222222222222222222222222'
|
||||
'222222222222222222222222222',
|
||||
@ -144,30 +144,30 @@ class FormatArgsTest(test_utils.BaseTestCase):
|
||||
self.assertEqual({'K1': 'V1',
|
||||
'K2': 'V22222222222222222222222222222'
|
||||
'222222222222222222222222222',
|
||||
'K3': '3.3.3.3'}, l)
|
||||
'K3': '3.3.3.3'}, li)
|
||||
|
||||
def test_format_args_multiple_colon_values(self):
|
||||
l = utils.format_args([
|
||||
li = utils.format_args([
|
||||
'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'}, li)
|
||||
|
||||
def test_format_args_parse_comma_false(self):
|
||||
l = utils.format_args(
|
||||
li = utils.format_args(
|
||||
['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'}, li)
|
||||
|
||||
def test_format_args_multiple_values_per_args(self):
|
||||
l = utils.format_args([
|
||||
li = utils.format_args([
|
||||
'K1=V1',
|
||||
'K1=V2'])
|
||||
self.assertIn('K1', l)
|
||||
self.assertIn('V1', l['K1'])
|
||||
self.assertIn('V2', l['K1'])
|
||||
self.assertIn('K1', li)
|
||||
self.assertIn('V1', li['K1'])
|
||||
self.assertIn('V2', li['K1'])
|
||||
|
||||
def test_format_args_bad_arg(self):
|
||||
args = ['K1=V1,K22.2.2.2']
|
||||
|
@ -91,9 +91,9 @@ class ShellTest(utils.TestCase):
|
||||
|
||||
def test_help(self):
|
||||
required = [
|
||||
'.*?^usage: ',
|
||||
'.*?^\s+stop\s+Stop specified container.',
|
||||
'.*?^See "zun help COMMAND" for help on a specific command',
|
||||
r'.*?^usage: ',
|
||||
r'.*?^\s+stop\s+Stop specified container.',
|
||||
r'.*?^See "zun help COMMAND" for help on a specific command',
|
||||
]
|
||||
stdout, stderr = self.shell('help')
|
||||
for r in required:
|
||||
@ -102,9 +102,9 @@ class ShellTest(utils.TestCase):
|
||||
|
||||
def test_help_on_subcommand(self):
|
||||
required = [
|
||||
'.*?^usage: zun create',
|
||||
'.*?^Create a container.',
|
||||
'.*?^Optional arguments:',
|
||||
r'.*?^usage: zun create',
|
||||
r'.*?^Create a container.',
|
||||
r'.*?^Optional arguments:',
|
||||
]
|
||||
stdout, stderr = self.shell('help create')
|
||||
for r in required:
|
||||
@ -113,9 +113,9 @@ class ShellTest(utils.TestCase):
|
||||
|
||||
def test_help_no_options(self):
|
||||
required = [
|
||||
'.*?^usage: ',
|
||||
'.*?^\s+stop\s+Stop specified container.',
|
||||
'.*?^See "zun help COMMAND" for help on a specific command',
|
||||
r'.*?^usage: ',
|
||||
r'.*?^\s+stop\s+Stop specified container.',
|
||||
r'.*?^See "zun help COMMAND" for help on a specific command',
|
||||
]
|
||||
stdout, stderr = self.shell('')
|
||||
for r in required:
|
||||
@ -126,10 +126,10 @@ class ShellTest(utils.TestCase):
|
||||
stdout, stderr = self.shell('bash-completion')
|
||||
# just check we have some output
|
||||
required = [
|
||||
'.*--format',
|
||||
'.*help',
|
||||
'.*show',
|
||||
'.*--name']
|
||||
r'.*--format',
|
||||
r'.*help',
|
||||
r'.*show',
|
||||
r'.*--name']
|
||||
for r in required:
|
||||
self.assertThat((stdout + stderr),
|
||||
matchers.MatchesRegex(r, re.DOTALL | re.MULTILINE))
|
||||
|
Loading…
Reference in New Issue
Block a user