]> khamidou — GitHub mirrors - kite.git/commitdiff
added utility test class
authorkarim hamidou <khamidou@gmail.com>
Sat, 23 Nov 2013 18:53:06 +0000 (19:53 +0100)
committerkarim hamidou <khamidou@gmail.com>
Sat, 23 Nov 2013 18:53:06 +0000 (19:53 +0100)
src/back/tests/tmpdir.py [new file with mode: 0644]

diff --git a/src/back/tests/tmpdir.py b/src/back/tests/tmpdir.py
new file mode 100644 (file)
index 0000000..09bbd02
--- /dev/null
@@ -0,0 +1,21 @@
+# base class for tests who need a temporary directory
+import unittest
+import shutil
+import tempfile
+import os
+
+class TestCaseWithTempDir(unittest.TestCase):
+    def setUp(self):
+        self.tmpdir = tempfile.mkdtemp()
+
+    def tearDown(self):
+        shutil.rmtree(self.tmpdir)
+
+class TestCaseWithTempFile(unittest.TestCase):
+    def setUp(self):
+        self.tmpfd, self.tmpfile = tempfile.mkstemp()
+
+    def tearDown(self):
+        os.remove(self.tmpfile)
+
+