diff --git a/ironic/tests/drivers/test_deploy_utils.py b/ironic/tests/drivers/test_deploy_utils.py index 7e1d1ce727..6bc7ce5195 100644 --- a/ironic/tests/drivers/test_deploy_utils.py +++ b/ironic/tests/drivers/test_deploy_utils.py @@ -20,8 +20,8 @@ import os import shutil import stat import tempfile +import time -import fixtures import mock from oslo_concurrency import processutils from oslo_config import cfg @@ -132,16 +132,9 @@ image=kernel """ +@mock.patch.object(time, 'sleep', lambda seconds: None) class PhysicalWorkTestCase(tests_base.TestCase): - def setUp(self): - super(PhysicalWorkTestCase, self).setUp() - - def noop(*args, **kwargs): - pass - - self.useFixture(fixtures.MonkeyPatch('time.sleep', noop)) - def _mock_calls(self, name_list): patch_list = [mock.patch.object(utils, name) for name in name_list] mock_list = [patcher.start() for patcher in patch_list] diff --git a/ironic/tests/drivers/test_pxe.py b/ironic/tests/drivers/test_pxe.py index 22cf11dfdd..ff92bf40e7 100644 --- a/ironic/tests/drivers/test_pxe.py +++ b/ironic/tests/drivers/test_pxe.py @@ -20,7 +20,6 @@ import os import tempfile -import fixtures import mock from oslo_concurrency import processutils from oslo_config import cfg @@ -703,9 +702,10 @@ class PXEDriverTestCase(db_base.DbTestCase): @mock.patch.object(deploy_utils, 'notify_deploy_complete') @mock.patch.object(deploy_utils, 'switch_pxe_config') @mock.patch.object(iscsi_deploy, 'InstanceImageCache') - def _test_continue_deploy(self, is_localboot, mock_image_cache, - mock_switch_config, notify_mock, - mock_node_boot_dev, mock_clean_pxe): + @mock.patch.object(deploy_utils, 'deploy') + def _test_continue_deploy(self, is_localboot, mock_deploy, + mock_image_cache, mock_switch_config, + notify_mock, mock_node_boot_dev, mock_clean_pxe): token_path = self._create_token_file() # set local boot @@ -720,15 +720,9 @@ class PXEDriverTestCase(db_base.DbTestCase): self.node.save() root_uuid = "12345678-1234-1234-1234-1234567890abcxyz" + mock_deploy.return_value = root_uuid boot_mode = None - def fake_deploy(**kwargs): - return root_uuid - - self.useFixture(fixtures.MonkeyPatch( - 'ironic.drivers.modules.deploy_utils.deploy', - fake_deploy)) - with task_manager.acquire(self.context, self.node.uuid) as task: task.driver.vendor._continue_deploy( task, address='123456', iqn='aaa-bbb', key='fake-56789') diff --git a/ironic/tests/drivers/test_ssh.py b/ironic/tests/drivers/test_ssh.py index 49e9b946c4..f70e213093 100644 --- a/ironic/tests/drivers/test_ssh.py +++ b/ironic/tests/drivers/test_ssh.py @@ -15,7 +15,8 @@ """Test class for Ironic SSH power driver.""" -import fixtures +import tempfile + import mock from oslo_concurrency import processutils from oslo_config import cfg @@ -74,8 +75,8 @@ class SSHValidateParametersTestCase(db_base.DbTestCase): def test__parse_driver_info_good_file(self): # make sure we get back the expected things d_info = db_utils.get_test_ssh_info('file') - tempdir = self.useFixture(fixtures.TempDir()) - key_path = tempdir.path + '/foo' + tempdir = tempfile.mkdtemp() + key_path = tempdir + '/foo' open(key_path, 'wt').close() d_info['ssh_key_filename'] = key_path node = obj_utils.get_test_node( diff --git a/ironic/tests/test_disk_partitioner.py b/ironic/tests/test_disk_partitioner.py index b8a2f31dad..00cbef5e4c 100644 --- a/ironic/tests/test_disk_partitioner.py +++ b/ironic/tests/test_disk_partitioner.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import fixtures +import eventlet import mock from testtools.matchers import HasLength @@ -23,17 +23,9 @@ from ironic.common import utils from ironic.tests import base +@mock.patch.object(eventlet.greenthread, 'sleep', lambda seconds: None) class DiskPartitionerTestCase(base.TestCase): - def setUp(self): - super(DiskPartitionerTestCase, self).setUp() - - def noop(*args, **kwargs): - pass - - self.useFixture(fixtures.MonkeyPatch('eventlet.greenthread.sleep', - noop)) - def test_add_partition(self): dp = disk_partitioner.DiskPartitioner('/dev/fake') dp.add_partition(1024)