Remove six
This library no longer supports Python 2, thus usage of six can be removed. Change-Id: I8d0c1cfd6dff375b3b7756a5b36c95a2df3f04c6
This commit is contained in:
parent
a12456c17c
commit
23e647539c
|
@ -24,8 +24,7 @@ import copy
|
|||
|
||||
from oslo_utils import reflection
|
||||
from oslo_utils import strutils
|
||||
import six
|
||||
from six.moves.urllib import parse
|
||||
from urllib import parse
|
||||
|
||||
from heatclient._i18n import _
|
||||
from heatclient import exc as exceptions
|
||||
|
@ -207,8 +206,7 @@ class BaseManager(HookableMixin):
|
|||
return self.client.delete(url)
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class ManagerWithFind(BaseManager):
|
||||
class ManagerWithFind(BaseManager, metaclass=abc.ABCMeta):
|
||||
"""Manager with additional `find()`/`findall()` methods."""
|
||||
|
||||
@abc.abstractmethod
|
||||
|
|
|
@ -13,10 +13,9 @@
|
|||
import copy
|
||||
import uuid
|
||||
|
||||
import six
|
||||
from six.moves.urllib import parse as urlparse
|
||||
from swiftclient import client as sc
|
||||
from swiftclient import utils as swiftclient_utils
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from heatclient._i18n import _
|
||||
from heatclient import exc
|
||||
|
@ -102,7 +101,7 @@ def create_temp_url(swift_client, name, timeout, container=None):
|
|||
key_header = 'x-account-meta-temp-url-key'
|
||||
if key_header not in swift_client.head_account():
|
||||
swift_client.post_account({
|
||||
key_header: six.text_type(uuid.uuid4())[:32]})
|
||||
key_header: str(uuid.uuid4())[:32]})
|
||||
|
||||
key = swift_client.head_account()[key_header]
|
||||
project_path = swift_client.url.split('/')[-1]
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
import sys
|
||||
|
||||
from osc_lib.command import command
|
||||
import six
|
||||
|
||||
|
||||
class RawFormat(command.ShowOne):
|
||||
|
@ -63,7 +62,7 @@ def indent_and_truncate(txt, spaces=0, truncate=False, truncate_limit=10,
|
|||
"""
|
||||
if txt is None:
|
||||
return
|
||||
lines = six.text_type(txt).splitlines()
|
||||
lines = str(txt).splitlines()
|
||||
if truncate and len(lines) > truncate_limit:
|
||||
lines = lines[-truncate_limit:]
|
||||
if truncate_prefix is not None:
|
||||
|
|
|
@ -24,8 +24,7 @@ from oslo_serialization import jsonutils
|
|||
from oslo_utils import encodeutils
|
||||
from oslo_utils import importutils
|
||||
import requests
|
||||
import six
|
||||
from six.moves.urllib import parse
|
||||
from urllib import parse
|
||||
|
||||
from heatclient._i18n import _
|
||||
from heatclient.common import utils
|
||||
|
@ -151,7 +150,7 @@ class HTTPClient(object):
|
|||
dump.append('')
|
||||
if resp.content:
|
||||
content = resp.content
|
||||
if isinstance(content, six.binary_type):
|
||||
if isinstance(content, bytes):
|
||||
content = content.decode()
|
||||
dump.extend([content, ''])
|
||||
LOG.debug('\n'.join(dump))
|
||||
|
|
|
@ -15,10 +15,9 @@
|
|||
|
||||
from collections import abc
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
from six.moves.urllib import error
|
||||
from six.moves.urllib import parse
|
||||
from six.moves.urllib import request
|
||||
from urllib import error
|
||||
from urllib import parse
|
||||
from urllib import request
|
||||
|
||||
from heatclient._i18n import _
|
||||
from heatclient.common import environment_format
|
||||
|
@ -92,7 +91,7 @@ def get_template_contents(template_file=None, template_url=None,
|
|||
% template_url)
|
||||
|
||||
try:
|
||||
if isinstance(tpl, six.binary_type):
|
||||
if isinstance(tpl, bytes):
|
||||
tpl = tpl.decode('utf-8')
|
||||
template = template_format.parse(tpl)
|
||||
except ValueError as e:
|
||||
|
@ -114,7 +113,7 @@ def resolve_template_get_files(template, files, template_base_url,
|
|||
def ignore_if(key, value):
|
||||
if key != 'get_file' and key != 'type':
|
||||
return True
|
||||
if not isinstance(value, six.string_types):
|
||||
if not isinstance(value, str):
|
||||
return True
|
||||
if (key == 'type' and
|
||||
not value.endswith(('.yaml', '.template'))):
|
||||
|
@ -130,7 +129,7 @@ def resolve_template_get_files(template, files, template_base_url,
|
|||
|
||||
def is_template(file_content):
|
||||
try:
|
||||
if isinstance(file_content, six.binary_type):
|
||||
if isinstance(file_content, bytes):
|
||||
file_content = file_content.decode('utf-8')
|
||||
template_format.parse(file_content)
|
||||
except (ValueError, TypeError):
|
||||
|
@ -144,7 +143,7 @@ def get_file_contents(from_data, files, base_url=None,
|
|||
|
||||
if recurse_if and recurse_if(from_data):
|
||||
if isinstance(from_data, dict):
|
||||
recurse_data = six.itervalues(from_data)
|
||||
recurse_data = from_data.values()
|
||||
else:
|
||||
recurse_data = from_data
|
||||
for value in recurse_data:
|
||||
|
|
|
@ -22,10 +22,9 @@ import uuid
|
|||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import encodeutils
|
||||
import prettytable
|
||||
import six
|
||||
from six.moves.urllib import error
|
||||
from six.moves.urllib import parse
|
||||
from six.moves.urllib import request
|
||||
from urllib import error
|
||||
from urllib import parse
|
||||
from urllib import request
|
||||
import yaml
|
||||
|
||||
from heatclient._i18n import _
|
||||
|
@ -123,10 +122,7 @@ def print_list(objs, fields, formatters=None, sortby_index=0,
|
|||
row.append(data)
|
||||
pt.add_row(row)
|
||||
|
||||
if six.PY3:
|
||||
print(encodeutils.safe_encode(pt.get_string(**kwargs)).decode())
|
||||
else:
|
||||
print(encodeutils.safe_encode(pt.get_string(**kwargs)))
|
||||
|
||||
|
||||
def link_formatter(links):
|
||||
|
@ -286,10 +282,7 @@ def print_update_list(lst, fields, formatters=None):
|
|||
|
||||
pt.add_row(row)
|
||||
|
||||
if six.PY3:
|
||||
print(encodeutils.safe_encode(pt.get_string()).decode())
|
||||
else:
|
||||
print(encodeutils.safe_encode(pt.get_string()))
|
||||
|
||||
|
||||
def find_resource(manager, name_or_id):
|
||||
|
|
|
@ -17,7 +17,6 @@ import logging
|
|||
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils
|
||||
import six
|
||||
|
||||
from heatclient.common import utils as heat_utils
|
||||
|
||||
|
@ -41,6 +40,6 @@ class BuildInfo(command.ShowOne):
|
|||
'api': heat_utils.json_formatter,
|
||||
'engine': heat_utils.json_formatter,
|
||||
}
|
||||
columns = sorted(list(six.iterkeys(result)))
|
||||
columns = sorted(list(result.keys()))
|
||||
return columns, utils.get_dict_properties(result, columns,
|
||||
formatters=formatters)
|
||||
|
|
|
@ -20,8 +20,7 @@ from osc_lib import exceptions as exc
|
|||
from osc_lib.i18n import _
|
||||
from osc_lib import utils
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
from six.moves.urllib import request
|
||||
from urllib import request
|
||||
|
||||
from heatclient.common import format_utils
|
||||
from heatclient.common import utils as heat_utils
|
||||
|
@ -184,8 +183,8 @@ def _resource_metadata(heat_client, args):
|
|||
{'stack': args.stack,
|
||||
'resource': args.resource})
|
||||
|
||||
data = list(six.itervalues(metadata))
|
||||
columns = list(six.iterkeys(metadata))
|
||||
data = list(metadata.values())
|
||||
columns = list(metadata.keys())
|
||||
return columns, data
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import logging
|
|||
from osc_lib.command import command
|
||||
from osc_lib import exceptions as exc
|
||||
from osc_lib.i18n import _
|
||||
import six
|
||||
|
||||
from heatclient.common import format_utils
|
||||
from heatclient.common import utils as heat_utils
|
||||
|
@ -80,8 +79,8 @@ def _show_resourcetype(heat_client, parsed_args):
|
|||
raise exc.CommandError(
|
||||
_('Resource type not found: %s') % parsed_args.resource_type)
|
||||
|
||||
rows = list(six.itervalues(data))
|
||||
columns = list(six.iterkeys(data))
|
||||
rows = list(data.values())
|
||||
columns = list(data.keys())
|
||||
return columns, rows
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ from osc_lib.command import command
|
|||
from osc_lib import exceptions as exc
|
||||
from osc_lib.i18n import _
|
||||
from osc_lib import utils
|
||||
import six
|
||||
|
||||
from heatclient.common import format_utils
|
||||
from heatclient import exc as heat_exc
|
||||
|
@ -95,8 +94,8 @@ class ShowSnapshot(format_utils.YamlFormat):
|
|||
% {'snapshot_id': snapshot_id,
|
||||
'stack_id': stack_id})
|
||||
|
||||
rows = list(six.itervalues(data))
|
||||
columns = list(six.iterkeys(data))
|
||||
rows = list(data.values())
|
||||
columns = list(data.keys())
|
||||
return columns, rows
|
||||
|
||||
|
||||
|
|
|
@ -18,8 +18,7 @@ import logging
|
|||
from osc_lib.command import command
|
||||
from osc_lib import exceptions as exc
|
||||
from osc_lib import utils
|
||||
import six
|
||||
from six.moves.urllib import request
|
||||
from urllib import request
|
||||
import yaml
|
||||
|
||||
from heatclient._i18n import _
|
||||
|
@ -181,8 +180,8 @@ def _create_config(heat_client, args):
|
|||
|
||||
config['name'] = args.name
|
||||
sc = heat_client.software_configs.create(**config).to_dict()
|
||||
rows = list(six.itervalues(sc))
|
||||
columns = list(six.iterkeys(sc))
|
||||
rows = list(sc.values())
|
||||
columns = list(sc.keys())
|
||||
return columns, rows
|
||||
|
||||
|
||||
|
|
|
@ -20,8 +20,7 @@ from osc_lib.command import command
|
|||
from osc_lib import exceptions as exc
|
||||
from osc_lib import utils
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
from six.moves.urllib import request
|
||||
from urllib import request
|
||||
import yaml
|
||||
|
||||
from heatclient._i18n import _
|
||||
|
@ -733,7 +732,7 @@ class DeleteStack(command.Command):
|
|||
|
||||
try:
|
||||
if not parsed_args.yes and sys.stdin.isatty():
|
||||
prompt_response = six.moves.input(
|
||||
prompt_response = input(
|
||||
_("Are you sure you want to delete this stack(s) [y/N]? ")
|
||||
).lower()
|
||||
if not prompt_response.startswith('y'):
|
||||
|
@ -919,8 +918,8 @@ class AbandonStack(format_utils.JsonFormat):
|
|||
except IOError as e:
|
||||
raise exc.CommandError(str(e))
|
||||
|
||||
data = list(six.itervalues(stack))
|
||||
columns = list(six.iterkeys(stack))
|
||||
data = list(stack.values())
|
||||
columns = list(stack.keys())
|
||||
return columns, data
|
||||
|
||||
|
||||
|
@ -963,8 +962,8 @@ class ExportStack(format_utils.JsonFormat):
|
|||
except IOError as e:
|
||||
raise exc.CommandError(str(e))
|
||||
|
||||
data = list(six.itervalues(data_info))
|
||||
columns = list(six.iterkeys(data_info))
|
||||
data = list(data_info.values())
|
||||
columns = list(data_info.keys())
|
||||
return columns, data
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ import logging
|
|||
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils
|
||||
import six
|
||||
|
||||
from heatclient._i18n import _
|
||||
from heatclient.common import format_utils
|
||||
|
@ -181,6 +180,6 @@ def _validate(heat_client, args):
|
|||
fields['files_container'] = args.files_container
|
||||
|
||||
validation = heat_client.stacks.validate(**fields)
|
||||
data = list(six.itervalues(validation))
|
||||
columns = list(six.iterkeys(validation))
|
||||
data = list(validation.values())
|
||||
columns = list(validation.keys())
|
||||
return columns, data
|
||||
|
|
|
@ -22,7 +22,6 @@ from keystoneauth1.identity import generic
|
|||
from keystoneauth1 import session as kssession
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import importutils
|
||||
import six
|
||||
|
||||
import heatclient
|
||||
from heatclient._i18n import _
|
||||
|
@ -610,7 +609,7 @@ def main(args=None):
|
|||
if '--debug' in args or '-d' in args:
|
||||
raise
|
||||
else:
|
||||
print(encodeutils.safe_encode(six.text_type(e)), file=sys.stderr)
|
||||
print(encodeutils.safe_encode(str(e)), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
import os
|
||||
|
||||
import six
|
||||
from tempest.lib.cli import base
|
||||
from tempest.lib.cli import output_parser
|
||||
from tempest.lib import exceptions as tempest_exc
|
||||
|
@ -48,7 +47,7 @@ class OpenStackClientTestBase(base.ClientTestBase):
|
|||
obj = {}
|
||||
items = self.parser.listing(output)
|
||||
for item in items:
|
||||
obj[item['Field']] = six.text_type(item['Value'])
|
||||
obj[item['Field']] = str(item['Value'])
|
||||
return dict((self._key_name(k), v) for k, v in obj.items())
|
||||
|
||||
def _key_name(self, key):
|
||||
|
@ -86,7 +85,7 @@ class OpenStackClientTestBase(base.ClientTestBase):
|
|||
self.openstack(cmd)
|
||||
except tempest_exc.CommandFailed as e:
|
||||
msg = "Stack not found: %s" % id
|
||||
if msg in six.text_type(e.stdout):
|
||||
if msg in str(e.stdout):
|
||||
return
|
||||
raise
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
import json
|
||||
|
||||
import requests
|
||||
import six
|
||||
|
||||
|
||||
class FakeStdout(object):
|
||||
|
@ -41,5 +40,5 @@ class FakeResponse(requests.Response):
|
|||
|
||||
self.headers.update(headers)
|
||||
self._content = json.dumps(data)
|
||||
if not isinstance(self._content, six.binary_type):
|
||||
if not isinstance(self._content, bytes):
|
||||
self._content = self._content.encode()
|
||||
|
|
|
@ -305,7 +305,7 @@ class TestResourceSignal(TestResource):
|
|||
self.assertEqual('Should only specify one of data or data-file',
|
||||
str(error))
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_resource_signal_file(self, urlopen):
|
||||
data = mock.Mock()
|
||||
data.read.side_effect = ['{"message":"Content"}']
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
|
||||
from unittest import mock
|
||||
|
||||
import io
|
||||
from osc_lib import exceptions as exc
|
||||
import six
|
||||
|
||||
from heatclient import exc as heat_exc
|
||||
from heatclient.osc.v1 import snapshot
|
||||
|
@ -160,7 +160,7 @@ class TestSnapshotDelete(TestStack):
|
|||
self.cmd.take_action,
|
||||
parsed_args)
|
||||
|
||||
@mock.patch('sys.stdin', spec=six.StringIO)
|
||||
@mock.patch('sys.stdin', spec=io.StringIO)
|
||||
def test_snapshot_delete_prompt(self, mock_stdin):
|
||||
arglist = ['my_stack', 'snapshot_id']
|
||||
mock_stdin.isatty.return_value = True
|
||||
|
@ -173,7 +173,7 @@ class TestSnapshotDelete(TestStack):
|
|||
self.stack_client.snapshot_delete.assert_called_with('my_stack',
|
||||
'snapshot_id')
|
||||
|
||||
@mock.patch('sys.stdin', spec=six.StringIO)
|
||||
@mock.patch('sys.stdin', spec=io.StringIO)
|
||||
def test_snapshot_delete_prompt_no(self, mock_stdin):
|
||||
arglist = ['my_stack', 'snapshot_id']
|
||||
mock_stdin.isatty.return_value = True
|
||||
|
|
|
@ -145,7 +145,7 @@ class TestCreateConfig(TestConfig):
|
|||
self.mock_client.software_configs.create.assert_called_with(
|
||||
**properties)
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_config_create_config_file(self, urlopen):
|
||||
properties = {
|
||||
'config': 'config',
|
||||
|
@ -172,7 +172,7 @@ class TestCreateConfig(TestConfig):
|
|||
self.mock_client.software_configs.create.assert_called_with(
|
||||
**properties)
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_config_create_definition_file(self, urlopen):
|
||||
definition = {
|
||||
'inputs': [
|
||||
|
|
|
@ -17,7 +17,6 @@ from unittest import mock
|
|||
|
||||
from osc_lib import exceptions as exc
|
||||
from osc_lib import utils
|
||||
import six
|
||||
import testscenarios
|
||||
import yaml
|
||||
|
||||
|
@ -274,7 +273,7 @@ class TestStackUpdate(TestStack):
|
|||
|
||||
ex = self.assertRaises(exc.CommandError, self.cmd.take_action,
|
||||
parsed_args)
|
||||
self.assertEqual("--rollback invalid value: foo", six.text_type(ex))
|
||||
self.assertEqual("--rollback invalid value: foo", str(ex))
|
||||
|
||||
def test_stack_update_parameters(self):
|
||||
template_path = ('/'.join(self.template_path.split('/')[:-1]) +
|
||||
|
@ -720,7 +719,7 @@ class TestStackDelete(TestStack):
|
|||
self.stack_client.delete.assert_any_call('stack3')
|
||||
self.assertEqual('Unable to delete 1 of the 3 stacks.', str(error))
|
||||
|
||||
@mock.patch('sys.stdin', spec=six.StringIO)
|
||||
@mock.patch('sys.stdin', spec=io.StringIO)
|
||||
def test_stack_delete_prompt(self, mock_stdin):
|
||||
arglist = ['my_stack']
|
||||
mock_stdin.isatty.return_value = True
|
||||
|
@ -732,7 +731,7 @@ class TestStackDelete(TestStack):
|
|||
mock_stdin.readline.assert_called_with()
|
||||
self.stack_client.delete.assert_called_with('my_stack')
|
||||
|
||||
@mock.patch('sys.stdin', spec=six.StringIO)
|
||||
@mock.patch('sys.stdin', spec=io.StringIO)
|
||||
def test_stack_delete_prompt_no(self, mock_stdin):
|
||||
arglist = ['my_stack']
|
||||
mock_stdin.isatty.return_value = True
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
import socket
|
||||
from unittest import mock
|
||||
|
||||
import io
|
||||
from keystoneauth1 import adapter
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
import testtools
|
||||
|
||||
from heatclient.common import http
|
||||
|
@ -608,7 +608,7 @@ class SessionClientTest(testtools.TestCase):
|
|||
e = self.assertRaises(exc.HTTPNotFound,
|
||||
client.request, '', 'GET')
|
||||
# Assert that the raised exception can be converted to string
|
||||
self.assertIsNotNone(six.text_type(e))
|
||||
self.assertIsNotNone(str(e))
|
||||
|
||||
def test_redirect_302_location(self):
|
||||
fake1 = fakes.FakeHTTPResponse(
|
||||
|
@ -687,7 +687,7 @@ class SessionClientTest(testtools.TestCase):
|
|||
auth=mock.ANY)
|
||||
e = self.assertRaises(exc.InvalidEndpoint,
|
||||
client.request, '', 'GET', redirect=True)
|
||||
self.assertEqual("Location not returned with 302", six.text_type(e))
|
||||
self.assertEqual("Location not returned with 302", str(e))
|
||||
|
||||
def test_no_redirect_302_no_location(self):
|
||||
fake = fakes.FakeHTTPResponse(
|
||||
|
@ -716,7 +716,7 @@ class SessionClientTest(testtools.TestCase):
|
|||
e = self.assertRaises(exc.HTTPMultipleChoices,
|
||||
client.request, '', 'GET')
|
||||
# Assert that the raised exception can be converted to string
|
||||
self.assertIsNotNone(six.text_type(e))
|
||||
self.assertIsNotNone(str(e))
|
||||
|
||||
def test_504_error_response(self):
|
||||
# for 504 we don't have specific exception type
|
||||
|
@ -766,7 +766,7 @@ class SessionClientTest(testtools.TestCase):
|
|||
{}
|
||||
)
|
||||
mock_dumps.return_value = "{'files': test}}"
|
||||
data = six.BytesIO(b'test')
|
||||
data = io.BytesIO(b'test')
|
||||
kwargs = {'endpoint_override': 'http://no.where/',
|
||||
'data': {'files': data}}
|
||||
client = http.SessionClient(mock.ANY)
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
from unittest import mock
|
||||
|
||||
import six
|
||||
import swiftclient.client
|
||||
import testscenarios
|
||||
import testtools
|
||||
|
@ -231,7 +230,7 @@ class DerivedConfigTest(testtools.TestCase):
|
|||
if not self.result_error:
|
||||
raise e
|
||||
self.assertIsInstance(e, self.result_error)
|
||||
self.assertEqual(self.result_error_msg, six.text_type(e))
|
||||
self.assertEqual(self.result_error_msg, str(e))
|
||||
|
||||
|
||||
class TempURLSignalTest(testtools.TestCase):
|
||||
|
@ -331,7 +330,7 @@ class TempURLSignalTest(testtools.TestCase):
|
|||
self.assertEqual((
|
||||
'Cannot use --os-no-client-auth, auth required to create '
|
||||
'a Swift TempURL.'),
|
||||
six.text_type(e))
|
||||
str(e))
|
||||
|
||||
@mock.patch.object(deployment_utils, 'create_temp_url')
|
||||
@mock.patch.object(deployment_utils, 'create_swift_client')
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
from unittest import mock
|
||||
|
||||
import six
|
||||
import testscenarios
|
||||
import testtools
|
||||
import yaml
|
||||
|
@ -106,4 +105,4 @@ but very:
|
|||
- incorrect
|
||||
"""
|
||||
ex = self.assertRaises(ValueError, environment_format.parse, yaml)
|
||||
self.assertIn('but very:\n ^', six.text_type(ex))
|
||||
self.assertIn('but very:\n ^', str(ex))
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
#
|
||||
# Copyright 2015 IBM Corp.
|
||||
|
||||
import io
|
||||
import json
|
||||
import six
|
||||
import yaml
|
||||
|
||||
from heatclient.common import format_utils
|
||||
|
@ -128,7 +128,7 @@ abcde
|
|||
truncate_postfix='truncated'))
|
||||
|
||||
def test_print_software_deployment_output(self):
|
||||
out = six.StringIO()
|
||||
out = io.StringIO()
|
||||
format_utils.print_software_deployment_output(
|
||||
{'deploy_stdout': ''}, out=out, name='deploy_stdout')
|
||||
self.assertEqual(
|
||||
|
@ -137,7 +137,7 @@ abcde
|
|||
ov = {'deploy_stdout': '', 'deploy_stderr': '1\n2\n3\n4\n5\n6\n7\n8\n9'
|
||||
'\n10\n11',
|
||||
'deploy_status_code': 0}
|
||||
out = six.StringIO()
|
||||
out = io.StringIO()
|
||||
format_utils.print_software_deployment_output(ov, out=out,
|
||||
name='deploy_stderr')
|
||||
self.assertEqual(
|
||||
|
@ -156,7 +156,7 @@ abcde
|
|||
11
|
||||
(truncated, view all with --long)
|
||||
''', out.getvalue())
|
||||
out = six.StringIO()
|
||||
out = io.StringIO()
|
||||
format_utils.print_software_deployment_output(ov, out=out,
|
||||
name='deploy_stderr',
|
||||
long=True)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
import json
|
||||
import os
|
||||
|
||||
import six
|
||||
import io
|
||||
|
||||
from heatclient.common import resource_formatter
|
||||
from heatclient.osc.v1 import resource
|
||||
|
@ -94,7 +94,7 @@ OS::Heat::RandomString" ];
|
|||
self.resources.append(v1_resources.Resource(None, r))
|
||||
|
||||
def test_resource_list(self):
|
||||
out = six.StringIO()
|
||||
out = io.StringIO()
|
||||
formatter = resource_formatter.ResourceDotFormatter()
|
||||
formatter.emit_list(None, self.resources, out, None)
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
from unittest import mock
|
||||
|
||||
from six.moves.urllib import parse
|
||||
import testtools
|
||||
from urllib import parse
|
||||
|
||||
from heatclient.common import utils
|
||||
from heatclient.v1 import resources
|
||||
|
|
|
@ -18,15 +18,15 @@ from unittest import mock
|
|||
import uuid
|
||||
|
||||
import fixtures
|
||||
import io
|
||||
from keystoneauth1 import fixture as keystone_fixture
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import encodeutils
|
||||
from requests_mock.contrib import fixture as rm_fixture
|
||||
import six
|
||||
from six.moves.urllib import parse
|
||||
from six.moves.urllib import request
|
||||
import testscenarios
|
||||
import testtools
|
||||
from urllib import parse
|
||||
from urllib import request
|
||||
import yaml
|
||||
|
||||
from heatclient._i18n import _
|
||||
|
@ -411,7 +411,7 @@ class ShellBase(TestCase):
|
|||
def shell(self, argstr):
|
||||
orig = sys.stdout
|
||||
try:
|
||||
sys.stdout = six.StringIO()
|
||||
sys.stdout = io.StringIO()
|
||||
_shell = heatclient.shell.HeatShell()
|
||||
_shell.main(argstr.split())
|
||||
self.subcommands = _shell.subcommands.keys()
|
||||
|
@ -525,7 +525,7 @@ class ShellTestNoMoxBase(TestCase):
|
|||
def shell(self, argstr):
|
||||
orig = sys.stdout
|
||||
try:
|
||||
sys.stdout = six.StringIO()
|
||||
sys.stdout = io.StringIO()
|
||||
_shell = heatclient.shell.HeatShell()
|
||||
_shell.main(argstr.split())
|
||||
self.subcommands = _shell.subcommands.keys()
|
||||
|
@ -1354,7 +1354,7 @@ class ShellTestUserPass(ShellBase):
|
|||
|
||||
def test_stack_create_url(self):
|
||||
self.register_keystone_auth_fixture()
|
||||
url_content = six.StringIO(
|
||||
url_content = io.StringIO(
|
||||
'{"AWSTemplateFormatVersion" : "2010-09-09"}')
|
||||
self.useFixture(fixtures.MockPatchObject(request, 'urlopen',
|
||||
return_value=url_content))
|
||||
|
@ -2001,7 +2001,7 @@ class ShellTestUserPass(ShellBase):
|
|||
|
||||
# the main thing this @mock.patch is doing here is keeping
|
||||
# sys.stdin untouched for later tests
|
||||
@mock.patch('sys.stdin', new_callable=six.StringIO)
|
||||
@mock.patch('sys.stdin', new_callable=io.StringIO)
|
||||
def test_stack_delete_prompt_with_tty(self, ms):
|
||||
self.register_keystone_auth_fixture()
|
||||
mock_stdin = mock.Mock()
|
||||
|
@ -2025,7 +2025,7 @@ class ShellTestUserPass(ShellBase):
|
|||
|
||||
# the main thing this @mock.patch is doing here is keeping
|
||||
# sys.stdin untouched for later tests
|
||||
@mock.patch('sys.stdin', new_callable=six.StringIO)
|
||||
@mock.patch('sys.stdin', new_callable=io.StringIO)
|
||||
def test_stack_delete_prompt_with_tty_y(self, ms):
|
||||
self.register_keystone_auth_fixture()
|
||||
mock_stdin = mock.Mock()
|
||||
|
@ -2159,7 +2159,7 @@ class ShellTestUserPass(ShellBase):
|
|||
|
||||
# the main thing this @mock.patch is doing here is keeping
|
||||
# sys.stdin untouched for later tests
|
||||
@mock.patch('sys.stdin', new_callable=six.StringIO)
|
||||
@mock.patch('sys.stdin', new_callable=io.StringIO)
|
||||
def test_snapshot_delete_prompt_with_tty(self, ms):
|
||||
self.register_keystone_auth_fixture()
|
||||
resp_dict = {"snapshot": {
|
||||
|
@ -2189,7 +2189,7 @@ class ShellTestUserPass(ShellBase):
|
|||
|
||||
# the main thing this @mock.patch is doing here is keeping
|
||||
# sys.stdin untouched for later tests
|
||||
@mock.patch('sys.stdin', new_callable=six.StringIO)
|
||||
@mock.patch('sys.stdin', new_callable=io.StringIO)
|
||||
def test_snapshot_delete_prompt_with_tty_y(self, ms):
|
||||
self.register_keystone_auth_fixture()
|
||||
resp_dict = {"snapshot": {
|
||||
|
@ -2477,7 +2477,7 @@ class ShellTestUserPass(ShellBase):
|
|||
exc.CommandError, self.shell,
|
||||
'output-show teststack/1 output1')
|
||||
self.assertIn('The Referenced Attribute (0 PublicIP) is incorrect.',
|
||||
six.text_type(error))
|
||||
str(error))
|
||||
|
||||
|
||||
class ShellTestActions(ShellBase):
|
||||
|
@ -3548,8 +3548,8 @@ class ShellTestConfig(ShellBase):
|
|||
}}
|
||||
|
||||
output = [
|
||||
six.StringIO(yaml.safe_dump(definition, indent=2)),
|
||||
six.StringIO('the config script'),
|
||||
io.StringIO(yaml.safe_dump(definition, indent=2)),
|
||||
io.StringIO('the config script'),
|
||||
]
|
||||
self.useFixture(fixtures.MockPatchObject(request, 'urlopen',
|
||||
side_effect=output))
|
||||
|
@ -4082,7 +4082,7 @@ class MockShellBase(TestCase):
|
|||
def shell(self, argstr):
|
||||
orig = sys.stdout
|
||||
try:
|
||||
sys.stdout = six.StringIO()
|
||||
sys.stdout = io.StringIO()
|
||||
_shell = heatclient.shell.HeatShell()
|
||||
_shell.main(argstr.split())
|
||||
self.subcommands = _shell.subcommands.keys()
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
from unittest import mock
|
||||
|
||||
import six
|
||||
import testscenarios
|
||||
import testtools
|
||||
import yaml
|
||||
|
@ -60,4 +59,4 @@ but very:
|
|||
- incorrect
|
||||
"""
|
||||
ex = self.assertRaises(ValueError, template_format.parse, yaml)
|
||||
self.assertIn('but very:\n ^', six.text_type(ex))
|
||||
self.assertIn('but very:\n ^', str(ex))
|
||||
|
|
|
@ -15,11 +15,11 @@ import json
|
|||
import tempfile
|
||||
from unittest import mock
|
||||
|
||||
import io
|
||||
from oslo_serialization import base64
|
||||
import six
|
||||
from six.moves.urllib import error
|
||||
import testtools
|
||||
from testtools import matchers
|
||||
from urllib import error
|
||||
import yaml
|
||||
|
||||
from heatclient.common import template_utils
|
||||
|
@ -37,8 +37,8 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
if url:
|
||||
def side_effect(args):
|
||||
if url == args:
|
||||
return six.BytesIO(content)
|
||||
with mock.patch('six.moves.urllib.request.urlopen') as mock_url:
|
||||
return io.BytesIO(content)
|
||||
with mock.patch('urllib.request.urlopen') as mock_url:
|
||||
mock_url.side_effect = side_effect
|
||||
template_utils.resolve_environment_urls(
|
||||
jenv.get('resource_registry'), files, env_base_url)
|
||||
|
@ -47,7 +47,7 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
template_utils.resolve_environment_urls(
|
||||
jenv.get('resource_registry'), files, env_base_url)
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_ignore_env_keys(self, mock_url):
|
||||
env_file = '/home/my/dir/env.yaml'
|
||||
env = b'''
|
||||
|
@ -57,7 +57,7 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
hooks: pre_create
|
||||
restricted_actions: replace
|
||||
'''
|
||||
mock_url.return_value = six.BytesIO(env)
|
||||
mock_url.return_value = io.BytesIO(env)
|
||||
_, env_dict = template_utils.process_environment_and_files(
|
||||
env_file)
|
||||
self.assertEqual(
|
||||
|
@ -67,7 +67,7 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
env_dict)
|
||||
mock_url.assert_called_with('file://%s' % env_file)
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_process_environment_file(self, mock_url):
|
||||
|
||||
env_file = '/home/my/dir/env.yaml'
|
||||
|
@ -75,8 +75,8 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
resource_registry:
|
||||
"OS::Thingy": "file:///home/b/a.yaml"
|
||||
'''
|
||||
mock_url.side_effect = [six.BytesIO(env), six.BytesIO(self.template_a),
|
||||
six.BytesIO(self.template_a)]
|
||||
mock_url.side_effect = [io.BytesIO(env), io.BytesIO(self.template_a),
|
||||
io.BytesIO(self.template_a)]
|
||||
|
||||
files, env_dict = template_utils.process_environment_and_files(
|
||||
env_file)
|
||||
|
@ -92,7 +92,7 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
mock.call('file:///home/b/a.yaml')
|
||||
])
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_process_environment_relative_file(self, mock_url):
|
||||
|
||||
env_file = '/home/my/dir/env.yaml'
|
||||
|
@ -102,8 +102,8 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
"OS::Thingy": a.yaml
|
||||
'''
|
||||
|
||||
mock_url.side_effect = [six.BytesIO(env), six.BytesIO(self.template_a),
|
||||
six.BytesIO(self.template_a)]
|
||||
mock_url.side_effect = [io.BytesIO(env), io.BytesIO(self.template_a),
|
||||
io.BytesIO(self.template_a)]
|
||||
|
||||
self.assertEqual(
|
||||
env_url,
|
||||
|
@ -139,7 +139,7 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
self.assertEqual({}, files)
|
||||
self.assertEqual({}, env)
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_process_environment_relative_file_up(self, mock_url):
|
||||
|
||||
env_file = '/home/my/dir/env.yaml'
|
||||
|
@ -148,8 +148,8 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
resource_registry:
|
||||
"OS::Thingy": ../bar/a.yaml
|
||||
'''
|
||||
mock_url.side_effect = [six.BytesIO(env), six.BytesIO(self.template_a),
|
||||
six.BytesIO(self.template_a)]
|
||||
mock_url.side_effect = [io.BytesIO(env), io.BytesIO(self.template_a),
|
||||
io.BytesIO(self.template_a)]
|
||||
|
||||
env_url = 'file://%s' % env_file
|
||||
self.assertEqual(
|
||||
|
@ -174,7 +174,7 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
mock.call('file:///home/my/bar/a.yaml')
|
||||
])
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_process_environment_url(self, mock_url):
|
||||
env = b'''
|
||||
resource_registry:
|
||||
|
@ -182,8 +182,8 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
'''
|
||||
url = 'http://no.where/some/path/to/file.yaml'
|
||||
tmpl_url = 'http://no.where/some/path/to/a.yaml'
|
||||
mock_url.side_effect = [six.BytesIO(env), six.BytesIO(self.template_a),
|
||||
six.BytesIO(self.template_a)]
|
||||
mock_url.side_effect = [io.BytesIO(env), io.BytesIO(self.template_a),
|
||||
io.BytesIO(self.template_a)]
|
||||
|
||||
files, env_dict = template_utils.process_environment_and_files(
|
||||
url)
|
||||
|
@ -197,12 +197,12 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
mock.call(tmpl_url)
|
||||
])
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_process_environment_empty_file(self, mock_url):
|
||||
|
||||
env_file = '/home/my/dir/env.yaml'
|
||||
env = b''
|
||||
mock_url.return_value = six.BytesIO(env)
|
||||
mock_url.return_value = io.BytesIO(env)
|
||||
|
||||
files, env_dict = template_utils.process_environment_and_files(
|
||||
env_file)
|
||||
|
@ -216,7 +216,7 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
self.assertEqual({}, env)
|
||||
self.assertEqual({}, files)
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_process_multiple_environments_and_files(self, mock_url):
|
||||
|
||||
env_file1 = '/home/my/dir/env1.yaml'
|
||||
|
@ -235,12 +235,12 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
"OS::Thingy2": "file:///home/b/b.yaml"
|
||||
'''
|
||||
|
||||
mock_url.side_effect = [six.BytesIO(env1),
|
||||
six.BytesIO(self.template_a),
|
||||
six.BytesIO(self.template_a),
|
||||
six.BytesIO(env2),
|
||||
six.BytesIO(self.template_a),
|
||||
six.BytesIO(self.template_a)]
|
||||
mock_url.side_effect = [io.BytesIO(env1),
|
||||
io.BytesIO(self.template_a),
|
||||
io.BytesIO(self.template_a),
|
||||
io.BytesIO(env2),
|
||||
io.BytesIO(self.template_a),
|
||||
io.BytesIO(self.template_a)]
|
||||
|
||||
files, env = template_utils.process_multiple_environments_and_files(
|
||||
[env_file1, env_file2])
|
||||
|
@ -267,7 +267,7 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
mock.call('file:///home/b/b.yaml')
|
||||
])
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_process_multiple_environments_default_resources(self, mock_url):
|
||||
|
||||
env_file1 = '/home/my/dir/env1.yaml'
|
||||
|
@ -289,16 +289,16 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
resource2:
|
||||
"OS::Thingy4": "file:///home/b/b.yaml"
|
||||
'''
|
||||
mock_url.side_effect = [six.BytesIO(env1),
|
||||
six.BytesIO(self.template_a),
|
||||
six.BytesIO(self.template_a),
|
||||
six.BytesIO(self.template_a),
|
||||
six.BytesIO(self.template_a),
|
||||
six.BytesIO(env2),
|
||||
six.BytesIO(self.template_a),
|
||||
six.BytesIO(self.template_a),
|
||||
six.BytesIO(self.template_a),
|
||||
six.BytesIO(self.template_a)]
|
||||
mock_url.side_effect = [io.BytesIO(env1),
|
||||
io.BytesIO(self.template_a),
|
||||
io.BytesIO(self.template_a),
|
||||
io.BytesIO(self.template_a),
|
||||
io.BytesIO(self.template_a),
|
||||
io.BytesIO(env2),
|
||||
io.BytesIO(self.template_a),
|
||||
io.BytesIO(self.template_a),
|
||||
io.BytesIO(self.template_a),
|
||||
io.BytesIO(self.template_a)]
|
||||
|
||||
files, env = template_utils.process_multiple_environments_and_files(
|
||||
[env_file1, env_file2])
|
||||
|
@ -378,7 +378,7 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
self.assertEqual(self.template_a.decode('utf-8'),
|
||||
files['http://no.where/path/to/b/a.yaml'])
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_process_multiple_environments_and_files_tracker(self, mock_url):
|
||||
# Setup
|
||||
env_file1 = '/home/my/dir/env1.yaml'
|
||||
|
@ -389,9 +389,9 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
resource_registry:
|
||||
"OS::Thingy1": "file:///home/b/a.yaml"
|
||||
'''
|
||||
mock_url.side_effect = [six.BytesIO(env1),
|
||||
six.BytesIO(self.template_a),
|
||||
six.BytesIO(self.template_a)]
|
||||
mock_url.side_effect = [io.BytesIO(env1),
|
||||
io.BytesIO(self.template_a),
|
||||
io.BytesIO(self.template_a)]
|
||||
|
||||
# Test
|
||||
env_file_list = []
|
||||
|
@ -419,7 +419,7 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
|
||||
])
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_process_environment_relative_file_tracker(self, mock_url):
|
||||
|
||||
env_file = '/home/my/dir/env.yaml'
|
||||
|
@ -428,9 +428,9 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
resource_registry:
|
||||
"OS::Thingy": a.yaml
|
||||
'''
|
||||
mock_url.side_effect = [six.BytesIO(env),
|
||||
six.BytesIO(self.template_a),
|
||||
six.BytesIO(self.template_a)]
|
||||
mock_url.side_effect = [io.BytesIO(env),
|
||||
io.BytesIO(self.template_a),
|
||||
io.BytesIO(self.template_a)]
|
||||
|
||||
self.assertEqual(
|
||||
env_url,
|
||||
|
@ -460,7 +460,7 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
|
||||
])
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_process_multiple_environments_empty_registry(self, mock_url):
|
||||
# Setup
|
||||
env_file1 = '/home/my/dir/env1.yaml'
|
||||
|
@ -473,10 +473,10 @@ class ShellEnvironmentTest(testtools.TestCase):
|
|||
env2 = b'''
|
||||
resource_registry:
|
||||
'''
|
||||
mock_url.side_effect = [six.BytesIO(env1),
|
||||
six.BytesIO(self.template_a),
|
||||
six.BytesIO(self.template_a),
|
||||
six.BytesIO(env2)]
|
||||
mock_url.side_effect = [io.BytesIO(env1),
|
||||
io.BytesIO(self.template_a),
|
||||
io.BytesIO(self.template_a),
|
||||
io.BytesIO(env2)]
|
||||
|
||||
# Test
|
||||
env_file_list = []
|
||||
|
@ -654,11 +654,11 @@ class TestGetTemplateContents(testtools.TestCase):
|
|||
matchers.MatchesRegex(
|
||||
'Error parsing template file://%s ' % tmpl_file.name))
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_get_template_contents_url(self, mock_url):
|
||||
tmpl = b'{"AWSTemplateFormatVersion" : "2010-09-09", "foo": "bar"}'
|
||||
url = 'http://no.where/path/to/a.yaml'
|
||||
mock_url.return_value = six.BytesIO(tmpl)
|
||||
mock_url.return_value = io.BytesIO(tmpl)
|
||||
|
||||
files, tmpl_parsed = template_utils.get_template_contents(
|
||||
template_url=url)
|
||||
|
@ -726,9 +726,9 @@ class TestGetTemplateContents(testtools.TestCase):
|
|||
[{'path': '/tmp/%s' % filename,
|
||||
'content': {'get_file': url},
|
||||
'encoding': 'b64'}]}}}}}
|
||||
with mock.patch('six.moves.urllib.request.urlopen') as mock_url:
|
||||
with mock.patch('urllib.request.urlopen') as mock_url:
|
||||
raw_content = base64.decode_as_bytes(content)
|
||||
response = six.BytesIO(raw_content)
|
||||
response = io.BytesIO(raw_content)
|
||||
mock_url.return_value = response
|
||||
files = {}
|
||||
template_utils.resolve_template_get_files(
|
||||
|
@ -746,13 +746,7 @@ ABOkDAABQSwUGAAAAAAEAAQBOAAAARwAAAAAA\n'''
|
|||
# zip has '\0' in stream
|
||||
self.assertIn(b'\0', base64.decode_as_bytes(content))
|
||||
decoded_content = base64.decode_as_bytes(content)
|
||||
if six.PY3:
|
||||
self.assertRaises(UnicodeDecodeError, decoded_content.decode)
|
||||
else:
|
||||
self.assertRaises(
|
||||
UnicodeDecodeError,
|
||||
json.dumps,
|
||||
{'content': decoded_content})
|
||||
self.check_non_utf8_content(
|
||||
filename=filename, content=content)
|
||||
|
||||
|
@ -762,13 +756,7 @@ ABOkDAABQSwUGAAAAAAEAAQBOAAAARwAAAAAA\n'''
|
|||
# utf6 has '\0' in stream
|
||||
self.assertIn(b'\0', base64.decode_as_bytes(content))
|
||||
decoded_content = base64.decode_as_bytes(content)
|
||||
if six.PY3:
|
||||
self.assertRaises(UnicodeDecodeError, decoded_content.decode)
|
||||
else:
|
||||
self.assertRaises(
|
||||
UnicodeDecodeError,
|
||||
json.dumps,
|
||||
{'content': decoded_content})
|
||||
self.check_non_utf8_content(filename=filename, content=content)
|
||||
|
||||
def test_get_gb18030_content(self):
|
||||
|
@ -777,17 +765,11 @@ ABOkDAABQSwUGAAAAAAEAAQBOAAAARwAAAAAA\n'''
|
|||
# gb18030 has no '\0' in stream
|
||||
self.assertNotIn('\0', base64.decode_as_bytes(content))
|
||||
decoded_content = base64.decode_as_bytes(content)
|
||||
if six.PY3:
|
||||
self.assertRaises(UnicodeDecodeError, decoded_content.decode)
|
||||
else:
|
||||
self.assertRaises(
|
||||
UnicodeDecodeError,
|
||||
json.dumps,
|
||||
{'content': decoded_content})
|
||||
self.check_non_utf8_content(filename=filename, content=content)
|
||||
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
class TestTemplateGetFileFunctions(testtools.TestCase):
|
||||
|
||||
hot_template = b'''heat_template_version: 2013-05-23
|
||||
|
@ -815,12 +797,12 @@ resources:
|
|||
|
||||
tmpl_file = '/home/my/dir/template.yaml'
|
||||
url = 'file:///home/my/dir/template.yaml'
|
||||
mock_url.side_effect = [six.BytesIO(self.hot_template),
|
||||
six.BytesIO(b'bar contents'),
|
||||
six.BytesIO(b'foo contents'),
|
||||
six.BytesIO(b'baz1 contents'),
|
||||
six.BytesIO(b'baz2 contents'),
|
||||
six.BytesIO(b'baz3 contents')]
|
||||
mock_url.side_effect = [io.BytesIO(self.hot_template),
|
||||
io.BytesIO(b'bar contents'),
|
||||
io.BytesIO(b'foo contents'),
|
||||
io.BytesIO(b'baz1 contents'),
|
||||
io.BytesIO(b'baz2 contents'),
|
||||
io.BytesIO(b'baz3 contents')]
|
||||
|
||||
files, tmpl_parsed = template_utils.get_template_contents(
|
||||
template_file=tmpl_file)
|
||||
|
@ -869,8 +851,8 @@ outputs:\n\
|
|||
contents:\n\
|
||||
value:\n\
|
||||
get_file: foo.yaml\n'''
|
||||
mock_url.side_effect = [six.BytesIO(contents),
|
||||
six.BytesIO(b'foo contents')]
|
||||
mock_url.side_effect = [io.BytesIO(contents),
|
||||
io.BytesIO(b'foo contents')]
|
||||
files = template_utils.get_template_contents(
|
||||
template_file=tmpl_file)[0]
|
||||
self.assertEqual({foo_url: b'foo contents'}, files)
|
||||
|
@ -892,8 +874,8 @@ outputs:\n\
|
|||
template:\n\
|
||||
value:\n\
|
||||
get_file: foo.yaml\n'''
|
||||
mock_url.side_effect = [six.BytesIO(contents),
|
||||
six.BytesIO(b'foo contents')]
|
||||
mock_url.side_effect = [io.BytesIO(contents),
|
||||
io.BytesIO(b'foo contents')]
|
||||
# asserts that is fetched only once even though it is
|
||||
# referenced in the template twice
|
||||
files = template_utils.get_template_contents(
|
||||
|
@ -935,18 +917,18 @@ parameters:
|
|||
type: string
|
||||
'''
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_hot_template(self, mock_url):
|
||||
tmpl_file = '/home/my/dir/template.yaml'
|
||||
url = 'file:///home/my/dir/template.yaml'
|
||||
|
||||
def side_effect(args):
|
||||
if url == args:
|
||||
return six.BytesIO(self.hot_template)
|
||||
return io.BytesIO(self.hot_template)
|
||||
if 'file:///home/my/dir/foo.yaml' == args:
|
||||
return six.BytesIO(self.foo_template)
|
||||
return io.BytesIO(self.foo_template)
|
||||
if 'file:///home/my/dir/spam/egg.yaml' == args:
|
||||
return six.BytesIO(self.egg_template)
|
||||
return io.BytesIO(self.egg_template)
|
||||
mock_url.side_effect = side_effect
|
||||
|
||||
files, tmpl_parsed = template_utils.get_template_contents(
|
||||
|
@ -1013,7 +995,7 @@ parameters:
|
|||
type: string
|
||||
'''
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_hot_template(self, mock_url):
|
||||
tmpl_file = '/home/my/dir/template.yaml'
|
||||
url = 'file:///home/my/dir/template.yaml'
|
||||
|
@ -1022,11 +1004,11 @@ parameters:
|
|||
|
||||
def side_effect(args):
|
||||
if url == args:
|
||||
return six.BytesIO(self.hot_template)
|
||||
return io.BytesIO(self.hot_template)
|
||||
if foo_url == args:
|
||||
return six.BytesIO(self.foo_template)
|
||||
return io.BytesIO(self.foo_template)
|
||||
if bar_url == args:
|
||||
return six.BytesIO(self.bar_template)
|
||||
return io.BytesIO(self.bar_template)
|
||||
mock_url.side_effect = side_effect
|
||||
|
||||
files, tmpl_parsed = template_utils.get_template_contents(
|
||||
|
@ -1112,7 +1094,7 @@ parameters:
|
|||
type: string
|
||||
'''
|
||||
|
||||
@mock.patch('six.moves.urllib.request.urlopen')
|
||||
@mock.patch('urllib.request.urlopen')
|
||||
def test_env_nested_includes(self, mock_url):
|
||||
env_file = '/home/my/dir/env.yaml'
|
||||
env_url = 'file:///home/my/dir/env.yaml'
|
||||
|
@ -1130,21 +1112,21 @@ parameters:
|
|||
|
||||
def side_effect(args):
|
||||
if env_url == args:
|
||||
return six.BytesIO(env)
|
||||
return io.BytesIO(env)
|
||||
if template_url == args:
|
||||
return six.BytesIO(self.hot_template)
|
||||
return io.BytesIO(self.hot_template)
|
||||
if foo_url == args:
|
||||
return six.BytesIO(self.foo_template)
|
||||
return io.BytesIO(self.foo_template)
|
||||
if egg_url == args:
|
||||
return six.BytesIO(self.egg_template)
|
||||
return io.BytesIO(self.egg_template)
|
||||
if ham_url == args:
|
||||
return six.BytesIO(b'ham contents')
|
||||
return io.BytesIO(b'ham contents')
|
||||
if one_url == args:
|
||||
return six.BytesIO(self.foo_template)
|
||||
return io.BytesIO(self.foo_template)
|
||||
if two_url == args:
|
||||
return six.BytesIO(self.foo_template)
|
||||
return io.BytesIO(self.foo_template)
|
||||
if three_url == args:
|
||||
return six.BytesIO(b'three contents')
|
||||
return io.BytesIO(b'three contents')
|
||||
mock_url.side_effect = side_effect
|
||||
|
||||
files, env_dict = template_utils.process_environment_and_files(
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
import collections
|
||||
from oslo_utils import encodeutils
|
||||
from six.moves.urllib import parse
|
||||
from urllib import parse
|
||||
|
||||
from heatclient.common import base
|
||||
from heatclient.common import utils
|
||||
|
|
|
@ -12,8 +12,7 @@
|
|||
# under the License.
|
||||
|
||||
from oslo_utils import encodeutils
|
||||
import six
|
||||
from six.moves.urllib import parse
|
||||
from urllib import parse
|
||||
|
||||
from heatclient.common import base
|
||||
from heatclient.common import utils
|
||||
|
@ -21,7 +20,7 @@ from heatclient.common import utils
|
|||
|
||||
class ResourceType(base.Resource):
|
||||
def __repr__(self):
|
||||
if isinstance(self._info, six.string_types):
|
||||
if isinstance(self._info, str):
|
||||
return "<ResourceType %s>" % self._info
|
||||
else:
|
||||
return "<ResourceType %s>" % self._info.get('resource_type')
|
||||
|
@ -30,7 +29,7 @@ class ResourceType(base.Resource):
|
|||
return self.manager.data(self, **kwargs)
|
||||
|
||||
def _add_details(self, info):
|
||||
if isinstance(info, six.string_types):
|
||||
if isinstance(info, str):
|
||||
self.resource_type = info
|
||||
elif isinstance(info, dict):
|
||||
self.resource_type = info.get('resource_type')
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
from oslo_utils import encodeutils
|
||||
from six.moves.urllib import parse
|
||||
from urllib import parse
|
||||
|
||||
from heatclient.common import base
|
||||
from heatclient.common import utils
|
||||
|
|
|
@ -18,8 +18,7 @@ import sys
|
|||
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import strutils
|
||||
import six
|
||||
from six.moves.urllib import request
|
||||
from urllib import request
|
||||
import yaml
|
||||
|
||||
from heatclient._i18n import _
|
||||
|
@ -306,7 +305,7 @@ def do_stack_delete(hc, args):
|
|||
|
||||
try:
|
||||
if not args.yes and sys.stdin.isatty():
|
||||
prompt_response = six.moves.input(
|
||||
prompt_response = input(
|
||||
_("Are you sure you want to delete this stack(s) [y/N]? ")
|
||||
).lower()
|
||||
if not prompt_response.startswith('y'):
|
||||
|
@ -542,7 +541,7 @@ def do_stack_update(hc, args):
|
|||
try:
|
||||
rollback = strutils.bool_from_string(args.rollback, strict=True)
|
||||
except ValueError as ex:
|
||||
raise exc.CommandError(six.text_type(ex))
|
||||
raise exc.CommandError(str(ex))
|
||||
else:
|
||||
fields['disable_rollback'] = not(rollback)
|
||||
# TODO(pshchelo): remove the following 'else' clause after deprecation
|
||||
|
@ -1067,7 +1066,7 @@ def do_resource_signal(hc, args):
|
|||
data_url = utils.normalise_file_path_to_url(data_file)
|
||||
data = request.urlopen(data_url).read()
|
||||
if data:
|
||||
if isinstance(data, six.binary_type):
|
||||
if isinstance(data, bytes):
|
||||
data = data.decode('utf-8')
|
||||
try:
|
||||
data = jsonutils.loads(data)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from six.moves.urllib import parse
|
||||
from urllib import parse
|
||||
|
||||
from heatclient.common import base
|
||||
from heatclient.common import utils
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from six.moves.urllib import parse
|
||||
from urllib import parse
|
||||
|
||||
from heatclient.common import base
|
||||
from heatclient.common import utils
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from six.moves.urllib import parse
|
||||
from urllib import parse
|
||||
|
||||
from heatclient._i18n import _
|
||||
from heatclient.common import base
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# under the License.
|
||||
|
||||
from oslo_utils import encodeutils
|
||||
from six.moves.urllib import parse
|
||||
from urllib import parse
|
||||
|
||||
from heatclient.common import base
|
||||
|
||||
|
|
|
@ -76,7 +76,6 @@ requests==2.14.2
|
|||
requestsexceptions==1.2.0
|
||||
rfc3986==0.3.1
|
||||
simplejson==3.5.1
|
||||
six==1.10.0
|
||||
snowballstemmer==1.2.1
|
||||
stestr==2.0.0
|
||||
stevedore==1.20.0
|
||||
|
|
|
@ -15,4 +15,3 @@ keystoneauth1>=3.8.0 # Apache-2.0
|
|||
python-swiftclient>=3.2.0 # Apache-2.0
|
||||
PyYAML>=3.13 # MIT
|
||||
requests>=2.14.2 # Apache-2.0
|
||||
six>=1.10.0 # MIT
|
||||
|
|
Loading…
Reference in New Issue