commit 84975cce3c48c511d0ff317078a7d9bdfc7eabac Author: xuanyandong Date: Thu Oct 8 10:58:09 2020 +0800 Remove six of dir cinder/tests/unit/policies&scheduler&targets/* Replace the following items with Python 3 style code. - six.moves - six.StringIO Change-Id: Ie3a490d95671629bf0014396602aae6a62fb2977 Implements: blueprint six-removal diff --git a/cinder/tests/unit/policies/test_default_volume_types.py b/cinder/tests/unit/policies/test_default_volume_types.py index d19aba5..17ccc5d 100644 --- a/cinder/tests/unit/policies/test_default_volume_types.py +++ b/cinder/tests/unit/policies/test_default_volume_types.py @@ -13,10 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from http import client as http_client from unittest import mock -from six.moves import http_client - from cinder.api import microversions as mv from cinder import db from cinder.tests.unit import fake_constants diff --git a/cinder/tests/unit/policies/test_volume.py b/cinder/tests/unit/policies/test_volume.py index 0aa2266..2718da4 100644 --- a/cinder/tests/unit/policies/test_volume.py +++ b/cinder/tests/unit/policies/test_volume.py @@ -11,10 +11,9 @@ # License for the specific language governing permissions and limitations # under the License. +from http import client as http_client from unittest import mock -from six.moves import http_client - from cinder.tests.unit import fake_constants from cinder.tests.unit.policies import test_base from cinder.volume import api as volume_api diff --git a/cinder/tests/unit/policies/test_volume_actions.py b/cinder/tests/unit/policies/test_volume_actions.py index bb8c713..3aa080c 100644 --- a/cinder/tests/unit/policies/test_volume_actions.py +++ b/cinder/tests/unit/policies/test_volume_actions.py @@ -11,10 +11,9 @@ # License for the specific language governing permissions and limitations # under the License. +from http import client as http_client from unittest import mock -from six.moves import http_client - from cinder.api import microversions as mv from cinder.tests.unit import fake_constants from cinder.tests.unit.policies import test_base diff --git a/cinder/tests/unit/policies/test_volume_metadata.py b/cinder/tests/unit/policies/test_volume_metadata.py index fc0d993..2ca3e23 100644 --- a/cinder/tests/unit/policies/test_volume_metadata.py +++ b/cinder/tests/unit/policies/test_volume_metadata.py @@ -11,10 +11,9 @@ # License for the specific language governing permissions and limitations # under the License. +from http import client as http_client from unittest import mock -from six.moves import http_client - from cinder.tests.unit.policies import test_base from cinder.volume import api as volume_api diff --git a/cinder/tests/unit/scheduler/test_scheduler_options.py b/cinder/tests/unit/scheduler/test_scheduler_options.py index c8e0449..941fc55 100644 --- a/cinder/tests/unit/scheduler/test_scheduler_options.py +++ b/cinder/tests/unit/scheduler/test_scheduler_options.py @@ -17,9 +17,9 @@ Tests For PickledScheduler. """ import datetime +import io from oslo_serialization import jsonutils -import six from cinder.scheduler import scheduler_options from cinder.tests.unit import test @@ -45,7 +45,7 @@ class FakeSchedulerOptions(scheduler_options.SchedulerOptions): def _get_file_handle(self, filename): self.file_was_loaded = True - return six.StringIO(self._file_data) + return io.StringIO(self._file_data) def _get_time_now(self): return self._time_now diff --git a/cinder/tests/unit/targets/test_iet_driver.py b/cinder/tests/unit/targets/test_iet_driver.py index effbb8a..4d265e1 100644 --- a/cinder/tests/unit/targets/test_iet_driver.py +++ b/cinder/tests/unit/targets/test_iet_driver.py @@ -11,10 +11,10 @@ # under the License. import contextlib +import io from unittest import mock from oslo_concurrency import processutils as putils -import six from cinder import context from cinder import exception @@ -31,7 +31,7 @@ class TestIetAdmDriver(tf.TargetDriverFixture): configuration=self.configuration) def test_get_target(self): - tmp_file = six.StringIO() + tmp_file = io.StringIO() tmp_file.write( 'tid:1 name:iqn.2010-10.org.openstack:' 'volume-83c2e877-feed-46be-8435-77884fe55b45\n' @@ -39,7 +39,7 @@ class TestIetAdmDriver(tf.TargetDriverFixture): 'iqn.1994-05.com.redhat:5a6894679665\n' ' cid:0 ip:10.9.8.7 state:active hd:none dd:none') tmp_file.seek(0) - with mock.patch('six.moves.builtins.open') as mock_open: + with mock.patch('builtins.open') as mock_open: mock_open.return_value = contextlib.closing(tmp_file) self.assertEqual('1', self.target._get_target( @@ -63,8 +63,8 @@ class TestIetAdmDriver(tf.TargetDriverFixture): def test_create_iscsi_target(self, mock_log, mock_chown, mock_exists, mock_new_logical_unit, mock_new_target, mock_get_targ): - tmp_file = six.StringIO() - with mock.patch('six.moves.builtins.open') as mock_open: + tmp_file = io.StringIO() + with mock.patch('builtins.open') as mock_open: mock_open.return_value = contextlib.closing(tmp_file) self.assertEqual( 0, @@ -154,7 +154,7 @@ class TestIetAdmDriver(tf.TargetDriverFixture): @mock.patch('cinder.privsep.targets.iet.delete_target') def test_find_sid_cid_for_target(self, mock_delete_target): - tmp_file = six.StringIO() + tmp_file = io.StringIO() tmp_file.write( 'tid:1 name:iqn.2010-10.org.openstack:' 'volume-83c2e877-feed-46be-8435-77884fe55b45\n' @@ -162,7 +162,7 @@ class TestIetAdmDriver(tf.TargetDriverFixture): 'iqn.1994-05.com.redhat:5a6894679665\n' ' cid:0 ip:10.9.8.7 state:active hd:none dd:none') tmp_file.seek(0) - with mock.patch('six.moves.builtins.open') as mock_open: + with mock.patch('builtins.open') as mock_open: mock_open.return_value = contextlib.closing(tmp_file) self.assertEqual(('844427031282176', '0'), self.target._find_sid_cid_for_target(