summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/events_test.py9
-rw-r--r--tests/file_test.py14
-rw-r--r--tests/utils.py10
3 files changed, 18 insertions, 15 deletions
diff --git a/tests/events_test.py b/tests/events_test.py
index b63ff84..adaf86f 100644
--- a/tests/events_test.py
+++ b/tests/events_test.py
@@ -39,7 +39,7 @@ from combox.file import (relative_path, purge_dir,
from combox.silo import ComboxSilo
from tests.utils import (get_config, shardedp, dirp, renamedp,
path_deletedp, rm_nodedirs, rm_configdir,
- purge_nodedirs)
+ purge_nodedirs, purge)
class TestEvents(object):
@@ -392,12 +392,7 @@ class TestEvents(object):
if path.exists(silo_path):
os.remove(silo_path)
- for f in self.purge_list:
- if path.exists(f) and path.isfile(f):
- os.remove(f)
- elif path.exists(f) and path.isdir(f):
- purge_dir(f)
- os.rmdir(f)
+ purge(self.purge_list)
@classmethod
diff --git a/tests/file_test.py b/tests/file_test.py
index 8065ff7..6517943 100644
--- a/tests/file_test.py
+++ b/tests/file_test.py
@@ -27,7 +27,7 @@ from shutil import copyfile
from combox.config import get_nodedirs
from combox.crypto import split_and_encrypt
from combox.file import *
-from tests.utils import get_config, rm_nodedirs, rm_configdir
+from tests.utils import get_config, rm_nodedirs, rm_configdir, purge
class TestFile(object):
@@ -185,6 +185,11 @@ class TestFile(object):
self.purge_list.append(new_dir)
+ def teardown(self):
+ """Cleans up things after each test in this class."""
+ purge(self.purge_list)
+
+
@classmethod
def teardown_class(self):
"""Purge the mess created by this test."""
@@ -192,10 +197,3 @@ class TestFile(object):
rm_shards(self.TEST_FILE, self.config)
rm_nodedirs(self.config)
rm_configdir()
-
- for f in self.purge_list:
- if path.exists(f) and path.isfile(f):
- os.remove(f)
- elif path.exists(f) and path.isdir(f):
- purge_dir(f)
- os.rmdir(f)
diff --git a/tests/utils.py b/tests/utils.py
index b9de2c8..ef9f482 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -69,6 +69,16 @@ def rm_nodedirs(config):
print "Problem deleting", node, e
+def purge(l):
+ """ Purges everything in list `l'"""
+ for f in l:
+ if path.exists(f) and path.isfile(f):
+ remove(f)
+ elif path.exists(f) and path.isdir(f):
+ purge_dir(f)
+ rmdir(f)
+
+
def purge_nodedirs(config):
"""Purges everything inside node directories."""
nodes = get_nodedirs(config)