@mock.patch.object(utils, 'LOG', autospec=True)
@mock.patch.object(shutil, 'rmtree', autospec=True)
@mock.patch.object(tempfile, 'mkdtemp', autospec=True)
def test_tempdir_mocked_error_on_rmtree(self, mkdtemp_mock, rmtree_mock, log_mock):
    self.config(tempdir='abc')
    mkdtemp_mock.return_value = 'temp-dir'
    rmtree_mock.side_effect = OSError
    with utils.tempdir() as tempdir:
        self.assertEqual('temp-dir', tempdir)
        tempdir_created = tempdir
    rmtree_mock.assert_called_once_with(tempdir_created)
    self.assertTrue(log_mock.error.called)
@mock.patch.object(utils, 'LOG', autospec=True)
@mock.patch.object(shutil, 'rmtree', autospec=True)
@mock.patch.object(tempfile, 'mkdtemp', autospec=True)
def test_tempdir_mocked_error_on_rmtree(self, mkdtemp_mock, rmtree_mock, log_mock):
    self.config(tempdir='abc')
    mkdtemp_mock.return_value = 'temp-dir'
    rmtree_mock.side_effect = OSError
    with utils.tempdir() as tempdir:
        self.assertEqual('temp-dir', tempdir)
        tempdir_created = tempdir
    rmtree_mock.assert_called_once_with(tempdir_created)
    self.assertTrue(log_mock.error.called)