Remove six
Remove six.moves Replace the following items with Python 3 style code. - six.moves.urllib - six.iteritems - six.PY2 - six.StringIO Change-Id: If3fe0e534b092d436e46fca944c2955911e38197
This commit is contained in:

committed by
Takashi Kajinami

parent
9c3c2c983e
commit
b625d7b182
@@ -15,7 +15,6 @@ import os
|
|||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import requests
|
import requests
|
||||||
import requests.auth
|
import requests.auth
|
||||||
import six
|
|
||||||
from tempest.lib import exceptions
|
from tempest.lib import exceptions
|
||||||
|
|
||||||
from aodhclient.tests.functional import base
|
from aodhclient.tests.functional import base
|
||||||
@@ -289,7 +288,7 @@ class AodhClientTest(base.ClientTestBase):
|
|||||||
def test(params):
|
def test(params):
|
||||||
result = self.aodh('alarm', params=params)
|
result = self.aodh('alarm', params=params)
|
||||||
alarm = self.details_multiple(result)[0]
|
alarm = self.details_multiple(result)[0]
|
||||||
for key, value in six.iteritems(expected_lines):
|
for key, value in expected_lines.items():
|
||||||
self.assertEqual(value, alarm[key])
|
self.assertEqual(value, alarm[key])
|
||||||
return alarm
|
return alarm
|
||||||
|
|
||||||
@@ -686,7 +685,7 @@ class AodhClientGnocchiRulesTest(base.ClientTestBase):
|
|||||||
alarm = self.details_multiple(result)[0]
|
alarm = self.details_multiple(result)[0]
|
||||||
ALARM_ID = alarm['alarm_id']
|
ALARM_ID = alarm['alarm_id']
|
||||||
self.assertEqual('alarm1', alarm['name'])
|
self.assertEqual('alarm1', alarm['name'])
|
||||||
metrics = "[u'cpu', u'cpu_util']" if six.PY2 else "['cpu', 'cpu_util']"
|
metrics = "['cpu', 'cpu_util']"
|
||||||
self.assertEqual(metrics, alarm['metrics'])
|
self.assertEqual(metrics, alarm['metrics'])
|
||||||
self.assertEqual('80.0', alarm['threshold'])
|
self.assertEqual('80.0', alarm['threshold'])
|
||||||
self.assertEqual('last', alarm['aggregation_method'])
|
self.assertEqual('last', alarm['aggregation_method'])
|
||||||
@@ -865,7 +864,7 @@ class AodhClientGnocchiRulesTest(base.ClientTestBase):
|
|||||||
% (ALARM_ID, METRIC1, METRIC2)))
|
% (ALARM_ID, METRIC1, METRIC2)))
|
||||||
alarm_updated = self.details_multiple(result)[0]
|
alarm_updated = self.details_multiple(result)[0]
|
||||||
self.assertEqual(ALARM_ID, alarm_updated["alarm_id"])
|
self.assertEqual(ALARM_ID, alarm_updated["alarm_id"])
|
||||||
metrics = "[u'cpu', u'cpu_util']" if six.PY2 else "['cpu', 'cpu_util']"
|
metrics = "['cpu', 'cpu_util']"
|
||||||
self.assertEqual(metrics, alarm_updated['metrics'])
|
self.assertEqual(metrics, alarm_updated['metrics'])
|
||||||
self.assertEqual('80.0', alarm_updated['threshold'])
|
self.assertEqual('80.0', alarm_updated['threshold'])
|
||||||
self.assertEqual('last', alarm_updated['aggregation_method'])
|
self.assertEqual('last', alarm_updated['aggregation_method'])
|
||||||
|
@@ -12,11 +12,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.
|
||||||
|
|
||||||
|
import io
|
||||||
import sys
|
import sys
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from keystoneauth1 import exceptions
|
from keystoneauth1 import exceptions
|
||||||
import six
|
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from aodhclient import shell
|
from aodhclient import shell
|
||||||
@@ -24,7 +24,7 @@ from aodhclient import shell
|
|||||||
|
|
||||||
class CliTest(testtools.TestCase):
|
class CliTest(testtools.TestCase):
|
||||||
|
|
||||||
@mock.patch('sys.stderr', six.StringIO())
|
@mock.patch('sys.stderr', io.StringIO())
|
||||||
def test_cli_http_error_with_details(self):
|
def test_cli_http_error_with_details(self):
|
||||||
shell.AodhShell().clean_up(
|
shell.AodhShell().clean_up(
|
||||||
None, None, exceptions.HttpError('foo', details='bar'))
|
None, None, exceptions.HttpError('foo', details='bar'))
|
||||||
@@ -32,7 +32,7 @@ class CliTest(testtools.TestCase):
|
|||||||
self.assertEqual(1, len(stderr_lines))
|
self.assertEqual(1, len(stderr_lines))
|
||||||
self.assertEqual('bar', stderr_lines[0])
|
self.assertEqual('bar', stderr_lines[0])
|
||||||
|
|
||||||
@mock.patch('sys.stderr', six.StringIO())
|
@mock.patch('sys.stderr', io.StringIO())
|
||||||
def test_cli_http_error_without_details(self):
|
def test_cli_http_error_without_details(self):
|
||||||
shell.AodhShell().clean_up(None, None, exceptions.HttpError('foo'))
|
shell.AodhShell().clean_up(None, None, exceptions.HttpError('foo'))
|
||||||
stderr_lines = sys.stderr.getvalue().splitlines()
|
stderr_lines = sys.stderr.getvalue().splitlines()
|
||||||
|
@@ -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.
|
||||||
import re
|
import re
|
||||||
from six.moves.urllib import parse as urllib_parse
|
from urllib import parse as urllib_parse
|
||||||
|
|
||||||
import pyparsing as pp
|
import pyparsing as pp
|
||||||
|
|
||||||
|
@@ -13,8 +13,6 @@
|
|||||||
# 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 six
|
|
||||||
|
|
||||||
|
|
||||||
class Manager(object):
|
class Manager(object):
|
||||||
DEFAULT_HEADERS = {
|
DEFAULT_HEADERS = {
|
||||||
@@ -26,7 +24,7 @@ class Manager(object):
|
|||||||
|
|
||||||
def _set_default_headers(self, kwargs):
|
def _set_default_headers(self, kwargs):
|
||||||
headers = kwargs.get('headers', {})
|
headers = kwargs.get('headers', {})
|
||||||
for k, v in six.iteritems(self.DEFAULT_HEADERS):
|
for k, v in self.DEFAULT_HEADERS.items():
|
||||||
if k not in headers:
|
if k not in headers:
|
||||||
headers[k] = v
|
headers[k] = v
|
||||||
kwargs['headers'] = headers
|
kwargs['headers'] = headers
|
||||||
|
@@ -10,5 +10,4 @@ oslo.serialization>=1.4.0 # Apache-2.0
|
|||||||
oslo.utils>=2.0.0 # Apache-2.0
|
oslo.utils>=2.0.0 # Apache-2.0
|
||||||
osprofiler>=1.4.0 # Apache-2.0
|
osprofiler>=1.4.0 # Apache-2.0
|
||||||
keystoneauth1>=1.0.0
|
keystoneauth1>=1.0.0
|
||||||
six
|
|
||||||
pyparsing
|
pyparsing
|
Reference in New Issue
Block a user