Remove six
We don't need this in a Python 3-only world. Change-Id: I468a65eb1a950467671fff36a2f27387b81a6dc8
This commit is contained in:
parent
f617dcfe25
commit
6df3bcd3ed
@ -103,7 +103,6 @@ restructuredtext-lint==1.1.1
|
|||||||
rfc3986==1.1.0
|
rfc3986==1.1.0
|
||||||
Routes==2.3.1
|
Routes==2.3.1
|
||||||
simplejson==3.13.2
|
simplejson==3.13.2
|
||||||
six==1.11.0
|
|
||||||
smmap==0.9.0
|
smmap==0.9.0
|
||||||
statsd==3.2.1
|
statsd==3.2.1
|
||||||
stestr==2.0.0
|
stestr==2.0.0
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
import abc
|
import abc
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import six
|
|
||||||
|
|
||||||
from zunclient.common.apiclient import exceptions
|
from zunclient.common.apiclient import exceptions
|
||||||
|
|
||||||
@ -51,8 +50,7 @@ def load_plugin(auth_system):
|
|||||||
return plugin_class(auth_system=auth_system)
|
return plugin_class(auth_system=auth_system)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class BaseAuthPlugin(object, metaclass=abc.ABCMeta):
|
||||||
class BaseAuthPlugin(object):
|
|
||||||
"""Base class for authentication plugins.
|
"""Base class for authentication plugins.
|
||||||
|
|
||||||
An authentication plugin needs to override at least the authenticate
|
An authentication plugin needs to override at least the authenticate
|
||||||
|
@ -23,8 +23,6 @@ Exception definitions.
|
|||||||
import inspect
|
import inspect
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from zunclient.i18n import _
|
from zunclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
@ -454,7 +452,7 @@ def from_response(response, method, url):
|
|||||||
kwargs["message"] = (error.get("message") or
|
kwargs["message"] = (error.get("message") or
|
||||||
error.get("faultstring"))
|
error.get("faultstring"))
|
||||||
kwargs["details"] = (error.get("details") or
|
kwargs["details"] = (error.get("details") or
|
||||||
six.text_type(body))
|
str(body))
|
||||||
elif content_type.startswith("text/"):
|
elif content_type.startswith("text/"):
|
||||||
kwargs["details"] = getattr(response, 'text', '')
|
kwargs["details"] = getattr(response, 'text', '')
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ Base utilities to build API operation managers and objects on top of.
|
|||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
import six.moves.urllib.parse as urlparse
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
from zunclient.common.apiclient import base
|
from zunclient.common.apiclient import base
|
||||||
|
|
||||||
|
@ -29,8 +29,6 @@ import decorator
|
|||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
import prettytable
|
import prettytable
|
||||||
import six
|
|
||||||
from six import moves
|
|
||||||
|
|
||||||
from zunclient.i18n import _
|
from zunclient.i18n import _
|
||||||
|
|
||||||
@ -209,10 +207,7 @@ def print_list(objs, fields, formatters=None, sortby_index=0,
|
|||||||
row.append(data)
|
row.append(data)
|
||||||
pt.add_row(row)
|
pt.add_row(row)
|
||||||
|
|
||||||
if six.PY3:
|
print(encodeutils.safe_encode(pt.get_string(**kwargs)).decode())
|
||||||
print(encodeutils.safe_encode(pt.get_string(**kwargs)).decode())
|
|
||||||
else:
|
|
||||||
print(encodeutils.safe_encode(pt.get_string(**kwargs)))
|
|
||||||
|
|
||||||
|
|
||||||
def keys_and_vals_to_strs(dictionary):
|
def keys_and_vals_to_strs(dictionary):
|
||||||
@ -223,7 +218,7 @@ def keys_and_vals_to_strs(dictionary):
|
|||||||
def to_str(k_or_v):
|
def to_str(k_or_v):
|
||||||
if isinstance(k_or_v, dict):
|
if isinstance(k_or_v, dict):
|
||||||
return keys_and_vals_to_strs(k_or_v)
|
return keys_and_vals_to_strs(k_or_v)
|
||||||
elif isinstance(k_or_v, six.text_type):
|
elif isinstance(k_or_v, str):
|
||||||
return str(k_or_v)
|
return str(k_or_v)
|
||||||
else:
|
else:
|
||||||
return k_or_v
|
return k_or_v
|
||||||
@ -245,14 +240,14 @@ def print_dict(dct, dict_property="Property", wrap=0, value_fields=None):
|
|||||||
for k, v in dct.items():
|
for k, v in dct.items():
|
||||||
# convert dict to str to check length
|
# convert dict to str to check length
|
||||||
if isinstance(v, dict) and not value_fields:
|
if isinstance(v, dict) and not value_fields:
|
||||||
v = six.text_type(keys_and_vals_to_strs(v))
|
v = str(keys_and_vals_to_strs(v))
|
||||||
if wrap > 0:
|
if wrap > 0:
|
||||||
v = textwrap.fill(six.text_type(v), wrap)
|
v = textwrap.fill(str(v), wrap)
|
||||||
elif wrap < 0:
|
elif wrap < 0:
|
||||||
raise ValueError(_("Wrap argument should be a positive integer"))
|
raise ValueError(_("Wrap argument should be a positive integer"))
|
||||||
# if value has a newline, add in multiple rows
|
# if value has a newline, add in multiple rows
|
||||||
# e.g. fault with stacktrace
|
# e.g. fault with stacktrace
|
||||||
if v and isinstance(v, six.string_types) and r'\n' in v:
|
if v and isinstance(v, str) and r'\n' in v:
|
||||||
lines = v.strip().split(r'\n')
|
lines = v.strip().split(r'\n')
|
||||||
col1 = k
|
col1 = k
|
||||||
for line in lines:
|
for line in lines:
|
||||||
@ -267,10 +262,7 @@ def print_dict(dct, dict_property="Property", wrap=0, value_fields=None):
|
|||||||
else:
|
else:
|
||||||
pt.add_row([k, v])
|
pt.add_row([k, v])
|
||||||
|
|
||||||
if six.PY3:
|
print(encodeutils.safe_encode(pt.get_string()).decode())
|
||||||
print(encodeutils.safe_encode(pt.get_string()).decode())
|
|
||||||
else:
|
|
||||||
print(encodeutils.safe_encode(pt.get_string()))
|
|
||||||
|
|
||||||
|
|
||||||
def get_password(max_password_prompts=3):
|
def get_password(max_password_prompts=3):
|
||||||
@ -280,7 +272,7 @@ def get_password(max_password_prompts=3):
|
|||||||
if hasattr(sys.stdin, "isatty") and sys.stdin.isatty():
|
if hasattr(sys.stdin, "isatty") and sys.stdin.isatty():
|
||||||
# Check for Ctrl-D
|
# Check for Ctrl-D
|
||||||
try:
|
try:
|
||||||
for __ in moves.range(max_password_prompts):
|
for __ in range(max_password_prompts):
|
||||||
pw1 = getpass.getpass("OS Password: ")
|
pw1 = getpass.getpass("OS Password: ")
|
||||||
if verify:
|
if verify:
|
||||||
pw2 = getpass.getpass("Please verify: ")
|
pw2 = getpass.getpass("Please verify: ")
|
||||||
|
@ -15,16 +15,17 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
from http import client as http_client
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
import socket
|
import socket
|
||||||
import ssl
|
import ssl
|
||||||
|
import urllib.parse as urlparse
|
||||||
|
|
||||||
from keystoneauth1 import adapter
|
from keystoneauth1 import adapter
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
import six
|
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
|
|
||||||
from zunclient import api_versions
|
from zunclient import api_versions
|
||||||
from zunclient import exceptions
|
from zunclient import exceptions
|
||||||
@ -93,7 +94,7 @@ class HTTPClient(object):
|
|||||||
_kwargs['key_file'] = kwargs.get('key_file', None)
|
_kwargs['key_file'] = kwargs.get('key_file', None)
|
||||||
_kwargs['insecure'] = kwargs.get('insecure', False)
|
_kwargs['insecure'] = kwargs.get('insecure', False)
|
||||||
elif parts.scheme == 'http':
|
elif parts.scheme == 'http':
|
||||||
_class = six.moves.http_client.HTTPConnection
|
_class = http_client.HTTPConnection
|
||||||
else:
|
else:
|
||||||
msg = 'Unsupported scheme: %s' % parts.scheme
|
msg = 'Unsupported scheme: %s' % parts.scheme
|
||||||
raise exceptions.EndpointException(msg)
|
raise exceptions.EndpointException(msg)
|
||||||
@ -105,7 +106,7 @@ class HTTPClient(object):
|
|||||||
try:
|
try:
|
||||||
return _class(*self.connection_params[1][0:2],
|
return _class(*self.connection_params[1][0:2],
|
||||||
**self.connection_params[2])
|
**self.connection_params[2])
|
||||||
except six.moves.http_client.InvalidURL:
|
except http_client.InvalidURL:
|
||||||
raise exceptions.EndpointException()
|
raise exceptions.EndpointException()
|
||||||
|
|
||||||
def log_curl_request(self, method, url, kwargs):
|
def log_curl_request(self, method, url, kwargs):
|
||||||
@ -195,7 +196,7 @@ class HTTPClient(object):
|
|||||||
]
|
]
|
||||||
body_str = ''.join(body_list)
|
body_str = ''.join(body_list)
|
||||||
self.log_http_response(resp, body_str)
|
self.log_http_response(resp, body_str)
|
||||||
body_iter = six.StringIO(body_str)
|
body_iter = io.StringIO(body_str)
|
||||||
else:
|
else:
|
||||||
self.log_http_response(resp)
|
self.log_http_response(resp)
|
||||||
|
|
||||||
@ -245,7 +246,7 @@ class HTTPClient(object):
|
|||||||
return self._http_request(url, method, **kwargs)
|
return self._http_request(url, method, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class VerifiedHTTPSConnection(six.moves.http_client.HTTPSConnection):
|
class VerifiedHTTPSConnection(http_client.HTTPSConnection):
|
||||||
"""httplib-compatibile connection using client-side SSL authentication
|
"""httplib-compatibile connection using client-side SSL authentication
|
||||||
|
|
||||||
:see http://code.activestate.com/recipes/
|
:see http://code.activestate.com/recipes/
|
||||||
@ -254,9 +255,9 @@ class VerifiedHTTPSConnection(six.moves.http_client.HTTPSConnection):
|
|||||||
|
|
||||||
def __init__(self, host, port, key_file=None, cert_file=None,
|
def __init__(self, host, port, key_file=None, cert_file=None,
|
||||||
ca_file=None, timeout=None, insecure=False):
|
ca_file=None, timeout=None, insecure=False):
|
||||||
six.moves.http_client.HTTPSConnection.__init__(self, host, port,
|
http_client.HTTPSConnection.__init__(self, host, port,
|
||||||
key_file=key_file,
|
key_file=key_file,
|
||||||
cert_file=cert_file)
|
cert_file=cert_file)
|
||||||
self.key_file = key_file
|
self.key_file = key_file
|
||||||
self.cert_file = cert_file
|
self.cert_file = cert_file
|
||||||
if ca_file is not None:
|
if ca_file is not None:
|
||||||
|
@ -13,9 +13,8 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
import six
|
from urllib import parse
|
||||||
from six.moves.urllib import parse
|
from urllib import request
|
||||||
from six.moves.urllib import request
|
|
||||||
|
|
||||||
from zunclient.common import template_format
|
from zunclient.common import template_format
|
||||||
from zunclient.common import utils
|
from zunclient.common import utils
|
||||||
@ -43,7 +42,7 @@ def get_template_contents(template_file=None, template_url=None,
|
|||||||
template_url)
|
template_url)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if isinstance(tpl, six.binary_type):
|
if isinstance(tpl, bytes):
|
||||||
tpl = tpl.decode('utf-8')
|
tpl = tpl.decode('utf-8')
|
||||||
template = template_format.parse(tpl)
|
template = template_format.parse(tpl)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
@ -56,7 +55,7 @@ def get_template_contents(template_file=None, template_url=None,
|
|||||||
|
|
||||||
def is_template(file_content):
|
def is_template(file_content):
|
||||||
try:
|
try:
|
||||||
if isinstance(file_content, six.binary_type):
|
if isinstance(file_content, bytes):
|
||||||
file_content = file_content.decode('utf-8')
|
file_content = file_content.decode('utf-8')
|
||||||
template_format.parse(file_content)
|
template_format.parse(file_content)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
|
@ -22,9 +22,8 @@ import shlex
|
|||||||
|
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import netutils
|
from oslo_utils import netutils
|
||||||
import six
|
from urllib import parse
|
||||||
from six.moves.urllib import parse
|
from urllib import request
|
||||||
from six.moves.urllib import request
|
|
||||||
from zunclient.common.apiclient import exceptions as apiexec
|
from zunclient.common.apiclient import exceptions as apiexec
|
||||||
from zunclient.common import cliutils as utils
|
from zunclient.common import cliutils as utils
|
||||||
from zunclient import exceptions as exc
|
from zunclient import exceptions as exc
|
||||||
@ -204,7 +203,7 @@ def list_availability_zones(zones):
|
|||||||
def parse_command(command):
|
def parse_command(command):
|
||||||
output = []
|
output = []
|
||||||
if command:
|
if command:
|
||||||
if isinstance(command, six.string_types):
|
if isinstance(command, str):
|
||||||
command = [command]
|
command = [command]
|
||||||
for c in command:
|
for c in command:
|
||||||
c = '"' + c + '"'
|
c = '"' + c + '"'
|
||||||
@ -391,7 +390,7 @@ def list_container_networks(networks):
|
|||||||
|
|
||||||
|
|
||||||
def encode_file_data(data):
|
def encode_file_data(data):
|
||||||
if six.PY3 and isinstance(data, str):
|
if isinstance(data, str):
|
||||||
data = data.encode('utf-8')
|
data = data.encode('utf-8')
|
||||||
return base64.b64encode(data).decode('utf-8')
|
return base64.b64encode(data).decode('utf-8')
|
||||||
|
|
||||||
|
@ -22,14 +22,13 @@ import os
|
|||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import select
|
import select
|
||||||
import signal
|
import signal
|
||||||
import six
|
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
import socket
|
import socket
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
import termios
|
import termios
|
||||||
import time
|
import time
|
||||||
import tty
|
import tty
|
||||||
|
from urllib import parse as urlparse
|
||||||
import websocket
|
import websocket
|
||||||
|
|
||||||
from zunclient.common.apiclient import exceptions as acexceptions
|
from zunclient.common.apiclient import exceptions as acexceptions
|
||||||
@ -110,7 +109,7 @@ class BaseClient(object):
|
|||||||
self.handle_stdin(event)
|
self.handle_stdin(event)
|
||||||
except select.error as e:
|
except select.error as e:
|
||||||
# POSIX signals interrupt select()
|
# POSIX signals interrupt select()
|
||||||
no = e.errno if six.PY3 else e[0]
|
no = e.errno
|
||||||
if no == errno.EINTR:
|
if no == errno.EINTR:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
|
|
||||||
from zunclient.common import utils as zun_utils
|
from zunclient.common import utils as zun_utils
|
||||||
from zunclient import exceptions as exc
|
from zunclient import exceptions as exc
|
||||||
@ -60,7 +59,7 @@ class CreateRegistry(command.ShowOne):
|
|||||||
opts['password'] = parsed_args.password
|
opts['password'] = parsed_args.password
|
||||||
opts = zun_utils.remove_null_parms(**opts)
|
opts = zun_utils.remove_null_parms(**opts)
|
||||||
registry = client.registries.create(**opts)
|
registry = client.registries.create(**opts)
|
||||||
return zip(*sorted(six.iteritems(registry._info['registry'])))
|
return zip(*sorted(registry._info['registry'].items()))
|
||||||
|
|
||||||
|
|
||||||
class ShowRegistry(command.ShowOne):
|
class ShowRegistry(command.ShowOne):
|
||||||
@ -83,7 +82,7 @@ class ShowRegistry(command.ShowOne):
|
|||||||
opts = zun_utils.remove_null_parms(**opts)
|
opts = zun_utils.remove_null_parms(**opts)
|
||||||
registry = client.registries.get(**opts)
|
registry = client.registries.get(**opts)
|
||||||
|
|
||||||
return zip(*sorted(six.iteritems(registry._info['registry'])))
|
return zip(*sorted(registry._info['registry'].items()))
|
||||||
|
|
||||||
|
|
||||||
class ListRegistry(command.Lister):
|
class ListRegistry(command.Lister):
|
||||||
@ -229,4 +228,4 @@ class UpdateRegistry(command.ShowOne):
|
|||||||
if not opts:
|
if not opts:
|
||||||
raise exc.CommandError("You must update at least one property")
|
raise exc.CommandError("You must update at least one property")
|
||||||
registry = client.registries.update(registry, **opts)
|
registry = client.registries.update(registry, **opts)
|
||||||
return zip(*sorted(six.iteritems(registry._info['registry'])))
|
return zip(*sorted(registry._info['registry'].items()))
|
||||||
|
@ -32,7 +32,6 @@ import sys
|
|||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
import six
|
|
||||||
|
|
||||||
from zunclient import api_versions
|
from zunclient import api_versions
|
||||||
from zunclient import client as base_client
|
from zunclient import client as base_client
|
||||||
@ -766,7 +765,7 @@ def main():
|
|||||||
map(encodeutils.safe_decode, sys.argv[1:]))
|
map(encodeutils.safe_decode, sys.argv[1:]))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug(e, exc_info=1)
|
logger.debug(e, exc_info=1)
|
||||||
print("ERROR: %s" % encodeutils.safe_encode(six.text_type(e)),
|
print("ERROR: %s" % encodeutils.safe_encode(str(e)),
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -12,10 +12,9 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import configparser as config_parser
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import six
|
|
||||||
import six.moves.configparser as config_parser
|
|
||||||
from tempest.lib.cli import base
|
from tempest.lib.cli import base
|
||||||
|
|
||||||
DEFAULT_CONFIG_FILE = os.path.join(os.path.dirname(__file__), 'test.conf')
|
DEFAULT_CONFIG_FILE = os.path.join(os.path.dirname(__file__), 'test.conf')
|
||||||
@ -55,11 +54,7 @@ class FunctionalTestBase(base.ClientTestBase):
|
|||||||
def _get_config(self):
|
def _get_config(self):
|
||||||
config_file = os.environ.get('ZUNCLIENT_TEST_CONFIG',
|
config_file = os.environ.get('ZUNCLIENT_TEST_CONFIG',
|
||||||
DEFAULT_CONFIG_FILE)
|
DEFAULT_CONFIG_FILE)
|
||||||
# SafeConfigParser was deprecated in Python 3.2
|
config = config_parser.ConfigParser()
|
||||||
if six.PY3:
|
|
||||||
config = config_parser.ConfigParser()
|
|
||||||
else:
|
|
||||||
config = config_parser.SafeConfigParser()
|
|
||||||
if not config.read(config_file):
|
if not config.read(config_file):
|
||||||
self.skipTest('Skipping, no test config found @ %s' % config_file)
|
self.skipTest('Skipping, no test config found @ %s' % config_file)
|
||||||
try:
|
try:
|
||||||
|
@ -13,10 +13,11 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from http import client as http_client
|
||||||
|
from io import StringIO
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
import six
|
|
||||||
|
|
||||||
from zunclient import api_versions
|
from zunclient import api_versions
|
||||||
from zunclient.common.apiclient import exceptions
|
from zunclient.common.apiclient import exceptions
|
||||||
@ -36,7 +37,7 @@ def _get_error_body(faultstring=None, debuginfo=None):
|
|||||||
return raw_body
|
return raw_body
|
||||||
|
|
||||||
|
|
||||||
HTTP_CLASS = six.moves.http_client.HTTPConnection
|
HTTP_CLASS = http_client.HTTPConnection
|
||||||
HTTPS_CLASS = http.VerifiedHTTPSConnection
|
HTTPS_CLASS = http.VerifiedHTTPSConnection
|
||||||
DEFAULT_TIMEOUT = 600
|
DEFAULT_TIMEOUT = 600
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ class HttpClientTest(utils.BaseTestCase):
|
|||||||
def test_server_exception_empty_body(self):
|
def test_server_exception_empty_body(self):
|
||||||
error_body = _get_error_body()
|
error_body = _get_error_body()
|
||||||
fake_resp = utils.FakeResponse({'content-type': 'application/json'},
|
fake_resp = utils.FakeResponse({'content-type': 'application/json'},
|
||||||
six.StringIO(error_body),
|
StringIO(error_body),
|
||||||
version=1,
|
version=1,
|
||||||
status=500)
|
status=500)
|
||||||
client = http.HTTPClient(
|
client = http.HTTPClient(
|
||||||
@ -84,7 +85,7 @@ class HttpClientTest(utils.BaseTestCase):
|
|||||||
error_msg = 'test error msg'
|
error_msg = 'test error msg'
|
||||||
error_body = _get_error_body(error_msg)
|
error_body = _get_error_body(error_msg)
|
||||||
fake_resp = utils.FakeResponse({'content-type': 'application/json'},
|
fake_resp = utils.FakeResponse({'content-type': 'application/json'},
|
||||||
six.StringIO(error_body),
|
StringIO(error_body),
|
||||||
version=1,
|
version=1,
|
||||||
status=500)
|
status=500)
|
||||||
client = http.HTTPClient(
|
client = http.HTTPClient(
|
||||||
@ -104,7 +105,7 @@ class HttpClientTest(utils.BaseTestCase):
|
|||||||
"File \\\"/usr/local/lib/python2.7/...")
|
"File \\\"/usr/local/lib/python2.7/...")
|
||||||
error_body = _get_error_body(error_msg, error_trace)
|
error_body = _get_error_body(error_msg, error_trace)
|
||||||
fake_resp = utils.FakeResponse({'content-type': 'application/json'},
|
fake_resp = utils.FakeResponse({'content-type': 'application/json'},
|
||||||
six.StringIO(error_body),
|
StringIO(error_body),
|
||||||
version=1,
|
version=1,
|
||||||
status=500)
|
status=500)
|
||||||
client = http.HTTPClient(
|
client = http.HTTPClient(
|
||||||
@ -229,7 +230,7 @@ class HttpClientTest(utils.BaseTestCase):
|
|||||||
def test_401_unauthorized_exception(self):
|
def test_401_unauthorized_exception(self):
|
||||||
error_body = _get_error_body()
|
error_body = _get_error_body()
|
||||||
fake_resp = utils.FakeResponse({'content-type': 'text/plain'},
|
fake_resp = utils.FakeResponse({'content-type': 'text/plain'},
|
||||||
six.StringIO(error_body),
|
StringIO(error_body),
|
||||||
version=1,
|
version=1,
|
||||||
status=401)
|
status=401)
|
||||||
client = http.HTTPClient(
|
client = http.HTTPClient(
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import six
|
|
||||||
|
|
||||||
from zunclient.common import cliutils
|
from zunclient.common import cliutils
|
||||||
from zunclient.common import utils
|
from zunclient.common import utils
|
||||||
@ -187,10 +186,11 @@ class FormatArgsTest(test_utils.BaseTestCase):
|
|||||||
class CliUtilsTest(test_utils.BaseTestCase):
|
class CliUtilsTest(test_utils.BaseTestCase):
|
||||||
|
|
||||||
def test_keys_and_vals_to_strs(self):
|
def test_keys_and_vals_to_strs(self):
|
||||||
dict_in = {six.u('a'): six.u('1'),
|
dict_in = {'a': '1',
|
||||||
six.u('b'): {six.u('x'): 1,
|
'b': {
|
||||||
'y': six.u('2'),
|
'x': 1,
|
||||||
six.u('z'): six.u('3')},
|
'y': '2',
|
||||||
|
'z': '3'},
|
||||||
'c': 7}
|
'c': 7}
|
||||||
|
|
||||||
dict_exp = collections.OrderedDict([
|
dict_exp = collections.OrderedDict([
|
||||||
@ -207,7 +207,7 @@ class CliUtilsTest(test_utils.BaseTestCase):
|
|||||||
('b', collections.OrderedDict(sorted(dict_out['b'].items()))),
|
('b', collections.OrderedDict(sorted(dict_out['b'].items()))),
|
||||||
('c', dict_out['c'])])
|
('c', dict_out['c'])])
|
||||||
|
|
||||||
self.assertEqual(six.text_type(dict_exp), six.text_type(dict_act))
|
self.assertEqual(str(dict_exp), str(dict_act))
|
||||||
|
|
||||||
|
|
||||||
class ParseNetsTest(test_utils.BaseTestCase):
|
class ParseNetsTest(test_utils.BaseTestCase):
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import io
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
from keystoneauth1 import fixture
|
from keystoneauth1 import fixture
|
||||||
import six
|
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
|
|
||||||
from zunclient import api_versions
|
from zunclient import api_versions
|
||||||
@ -225,8 +225,8 @@ class ShellTest(utils.TestCase):
|
|||||||
self.fail('CommandError not raised')
|
self.fail('CommandError not raised')
|
||||||
|
|
||||||
@mock.patch('sys.argv', ['zun'])
|
@mock.patch('sys.argv', ['zun'])
|
||||||
@mock.patch('sys.stdout', six.StringIO())
|
@mock.patch('sys.stdout', io.StringIO())
|
||||||
@mock.patch('sys.stderr', six.StringIO())
|
@mock.patch('sys.stderr', io.StringIO())
|
||||||
def test_main_noargs(self):
|
def test_main_noargs(self):
|
||||||
# Ensure that main works with no command-line arguments
|
# Ensure that main works with no command-line arguments
|
||||||
try:
|
try:
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
|
|
||||||
import copy
|
import copy
|
||||||
import datetime
|
import datetime
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
import six
|
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from zunclient import api_versions
|
from zunclient import api_versions
|
||||||
@ -54,7 +54,7 @@ class FakeAPI(object):
|
|||||||
|
|
||||||
def raw_request(self, *args, **kwargs):
|
def raw_request(self, *args, **kwargs):
|
||||||
response = self._request(*args, **kwargs)
|
response = self._request(*args, **kwargs)
|
||||||
body_iter = http.ResponseBodyIterator(six.StringIO(response[1]))
|
body_iter = http.ResponseBodyIterator(io.StringIO(response[1]))
|
||||||
return FakeResponse(response[0]), body_iter
|
return FakeResponse(response[0]), body_iter
|
||||||
|
|
||||||
def json_request(self, *args, **kwargs):
|
def json_request(self, *args, **kwargs):
|
||||||
@ -150,8 +150,8 @@ class TestCase(testtools.TestCase):
|
|||||||
orig = sys.stdout
|
orig = sys.stdout
|
||||||
orig_stderr = sys.stderr
|
orig_stderr = sys.stderr
|
||||||
try:
|
try:
|
||||||
sys.stdout = six.StringIO()
|
sys.stdout = io.StringIO()
|
||||||
sys.stderr = six.StringIO()
|
sys.stderr = io.StringIO()
|
||||||
_shell = shell.OpenStackZunShell()
|
_shell = shell.OpenStackZunShell()
|
||||||
_shell.main(argstr.split())
|
_shell.main(argstr.split())
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
|
@ -11,9 +11,10 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
from six.moves.urllib import parse
|
|
||||||
import testtools
|
import testtools
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
|
from urllib import parse
|
||||||
from zunclient.common import utils as zun_utils
|
from zunclient.common import utils as zun_utils
|
||||||
from zunclient import exceptions
|
from zunclient import exceptions
|
||||||
from zunclient.tests.unit import utils
|
from zunclient.tests.unit import utils
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from six.moves.urllib import parse
|
from urllib import parse
|
||||||
|
|
||||||
from zunclient import api_versions
|
from zunclient import api_versions
|
||||||
from zunclient.common import base
|
from zunclient.common import base
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from six.moves.urllib import parse
|
from urllib import parse
|
||||||
|
|
||||||
from zunclient.common import base
|
from zunclient.common import base
|
||||||
from zunclient.common import utils
|
from zunclient.common import utils
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from six.moves import urllib
|
import urllib
|
||||||
|
|
||||||
from zunclient.common import base
|
from zunclient.common import base
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user