From 4b1323af17f144724d5ca0c8c35f1aa5253655f6 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Thu, 30 Jun 2011 18:15:26 +0200 Subject: Secure removal of the temp file used by the testing suite --- test/clean.jpg | Bin 47793 -> 1328 bytes test/clean.png | Bin 1345 -> 4469 bytes test/dirty.jpg | Bin 47818 -> 1425 bytes test/dirty.png | Bin 1382 -> 4512 bytes test/test.py | 19 ++++++++++++------- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/test/clean.jpg b/test/clean.jpg index be06da5..4e89b40 100644 Binary files a/test/clean.jpg and b/test/clean.jpg differ diff --git a/test/clean.png b/test/clean.png index 2ce9efd..9339196 100644 Binary files a/test/clean.png and b/test/clean.png differ diff --git a/test/dirty.jpg b/test/dirty.jpg index a075590..71c32c7 100644 Binary files a/test/dirty.jpg and b/test/dirty.jpg differ diff --git a/test/dirty.png b/test/dirty.png index f37213f..5e4c093 100644 Binary files a/test/dirty.png and b/test/dirty.png differ 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 @@ ''' import shutil +import os import glob import sys import tempfile @@ -18,14 +19,18 @@ FILE_LIST = zip(glob.glob('clean*'), glob.glob('dirty*')) class MATTest(unittest.TestCase): def setUp(self): '''create working copy of the clean and the dirty file in the TMP dir''' - self.file_list = [] - self.tmpdir = tempfile.mkdtemp() + self.file_list = [] + self.tmpdir = tempfile.mkdtemp() - for clean, dirty in FILE_LIST: - shutil.copy2(clean, self.tmpdir + clean) - shutil.copy2(dirty, self.tmpdir + dirty) - self.file_list.append((self.tmpdir + clean, self.tmpdir + dirty)) + for clean, dirty in FILE_LIST: + shutil.copy2(clean, self.tmpdir + clean) + shutil.copy2(dirty, self.tmpdir + dirty) + self.file_list.append((self.tmpdir + clean, self.tmpdir + dirty)) def tearDown(self): '''Remove the tmp folder''' - shutil.rmtree(self.tmpdir) + for root, dirs, files in os.walk(self.tmpdir, topdown=False): + for name in files: + mat.secure_remove(os.path.join(toor, name)) + for name in dirs: + os.rmdir(os.path.join(root, name)) -- cgit v1.3