summaryrefslogtreecommitdiff
path: root/tests/unittests/helpers.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unittests/helpers.py')
-rw-r--r--tests/unittests/helpers.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/unittests/helpers.py b/tests/unittests/helpers.py
index de2cf638..1cdc05a1 100644
--- a/tests/unittests/helpers.py
+++ b/tests/unittests/helpers.py
@@ -252,6 +252,20 @@ class HttprettyTestCase(TestCase):
super(HttprettyTestCase, self).tearDown()
+class TempDirTestCase(TestCase):
+ # provide a tempdir per class, not per test.
+ def setUp(self):
+ super(TempDirTestCase, self).setUp()
+ self.tmp = tempfile.mkdtemp()
+ self.addCleanup(shutil.rmtree, self.tmp)
+
+ def tmp_path(self, path):
+ if path.startswith(os.path.sep):
+ path = "." + path
+
+ return os.path.normpath(os.path.join(self.tmp, path))
+
+
def populate_dir(path, files):
if not os.path.exists(path):
os.makedirs(path)