Skip to content

Commit

Permalink
Use tempfile and cleanup in windows unit test
Browse files Browse the repository at this point in the history
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
  • Loading branch information
j-griffith committed Sep 3, 2013
1 parent 1428e6f commit f0ab7be
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cinder/tests/test_windows.py
Expand Up @@ -21,6 +21,8 @@


import os
import shutil
import tempfile

from oslo.config import cfg

Expand All @@ -47,11 +49,12 @@ def __init__(self, method):
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)
Expand All @@ -63,6 +66,7 @@ def setUp(self):
def tearDown(self):
self._mox.UnsetStubs()
self.stubs.UnsetAll()
shutil.rmtree(self.lun_path_tempdir)
super(TestWindowsDriver, self).tearDown()

def _setup_stubs(self):
Expand Down

0 comments on commit f0ab7be

Please sign in to comment.