summaryrefslogtreecommitdiff
path: root/test/test.py
diff options
context:
space:
mode:
authorjvoisin2011-06-30 18:15:26 +0200
committerjvoisin2011-06-30 18:15:26 +0200
commit4b1323af17f144724d5ca0c8c35f1aa5253655f6 (patch)
tree48cdf2b7eb4d60e0a82d4d828a16ee707c54c957 /test/test.py
parenta62aab0c52c0826097f2f883c9c9aa8f9b66a5e8 (diff)
Secure removal of the temp file used by the testing suite
Diffstat (limited to 'test/test.py')
-rw-r--r--test/test.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/test/test.py b/test/test.py
index f095157..f856394 100644
--- a/test/test.py
+++ b/test/test.py
@@ -6,6 +6,7 @@
6''' 6'''
7 7
8import shutil 8import shutil
9import os
9import glob 10import glob
10import sys 11import sys
11import tempfile 12import tempfile
@@ -18,14 +19,18 @@ FILE_LIST = zip(glob.glob('clean*'), glob.glob('dirty*'))
18class MATTest(unittest.TestCase): 19class MATTest(unittest.TestCase):
19 def setUp(self): 20 def setUp(self):
20 '''create working copy of the clean and the dirty file in the TMP dir''' 21 '''create working copy of the clean and the dirty file in the TMP dir'''
21 self.file_list = [] 22 self.file_list = []
22 self.tmpdir = tempfile.mkdtemp() 23 self.tmpdir = tempfile.mkdtemp()
23 24
24 for clean, dirty in FILE_LIST: 25 for clean, dirty in FILE_LIST:
25 shutil.copy2(clean, self.tmpdir + clean) 26 shutil.copy2(clean, self.tmpdir + clean)
26 shutil.copy2(dirty, self.tmpdir + dirty) 27 shutil.copy2(dirty, self.tmpdir + dirty)
27 self.file_list.append((self.tmpdir + clean, self.tmpdir + dirty)) 28 self.file_list.append((self.tmpdir + clean, self.tmpdir + dirty))
28 29
29 def tearDown(self): 30 def tearDown(self):
30 '''Remove the tmp folder''' 31 '''Remove the tmp folder'''
31 shutil.rmtree(self.tmpdir) 32 for root, dirs, files in os.walk(self.tmpdir, topdown=False):
33 for name in files:
34 mat.secure_remove(os.path.join(toor, name))
35 for name in dirs:
36 os.rmdir(os.path.join(root, name))