From f0ab7be7c304dad9d925dbc6a82c67ec5bbfc1da Mon Sep 17 00:00:00 2001 From: John Griffith Date: Tue, 3 Sep 2013 22:33:24 +0000 Subject: [PATCH] Use tempfile and cleanup in windows unit test The unit test test_windows was setting and creating a directory c://iSCSIVirtualDisks in the root path and even worse wasn't deleting it on cleanup. This patch converts that to use tempfile and also adds an shutil.rmtree to the teardown method to clean up all the junk it creates. Fixes bug: 1219950 Change-Id: Ibd071c9c3ae9a02f26c85a09e8bc6619d8c73a37 --- cinder/tests/test_windows.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cinder/tests/test_windows.py b/cinder/tests/test_windows.py index af9697395..deca44bff 100644 --- a/cinder/tests/test_windows.py +++ b/cinder/tests/test_windows.py @@ -21,6 +21,8 @@ Unit tests for Windows Server 2012 OpenStack Cinder volume driver import os +import shutil +import tempfile from oslo.config import cfg @@ -47,11 +49,12 @@ class TestWindowsDriver(test.TestCase): super(TestWindowsDriver, self).__init__(method) def setUp(self): + self.lun_path_tempdir = tempfile.mkdtemp() super(TestWindowsDriver, self).setUp() self._mox = mox_lib.Mox() self.stubs = stubout.StubOutForTesting() self.flags( - windows_iscsi_lun_path='C:\iSCSIVirtualDisks', + windows_iscsi_lun_path=self.lun_path_tempdir, ) self._setup_stubs() configuration = conf.Configuration(None) @@ -63,6 +66,7 @@ class TestWindowsDriver(test.TestCase): def tearDown(self): self._mox.UnsetStubs() self.stubs.UnsetAll() + shutil.rmtree(self.lun_path_tempdir) super(TestWindowsDriver, self).tearDown() def _setup_stubs(self): -- 2.45.2