From 227795db020d0f64012c63fcd19eaaa723b35636 Mon Sep 17 00:00:00 2001 From: karim hamidou Date: Sat, 23 Nov 2013 19:53:06 +0100 Subject: [PATCH] added utility test class --- src/back/tests/tmpdir.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/back/tests/tmpdir.py diff --git a/src/back/tests/tmpdir.py b/src/back/tests/tmpdir.py new file mode 100644 index 0000000..09bbd02 --- /dev/null +++ b/src/back/tests/tmpdir.py @@ -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) + + -- 2.43.0