summaryrefslogtreecommitdiff
path: root/src/leap/testing/basetest.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-08-23 03:20:39 +0900
committerkali <kali@leap.se>2012-08-23 03:20:39 +0900
commit62400207b65644c5238e4e2aa895d78bb844f3a0 (patch)
tree44d9f130847241332fb8488516097f4ab1989fe8 /src/leap/testing/basetest.py
parent24f288b5214b814e2e7daa6ef41b226a27d96b81 (diff)
base leap testcase that creates a tempdir and changes path there
Diffstat (limited to 'src/leap/testing/basetest.py')
-rw-r--r--src/leap/testing/basetest.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/leap/testing/basetest.py b/src/leap/testing/basetest.py
new file mode 100644
index 00000000..ccf1a76f
--- /dev/null
+++ b/src/leap/testing/basetest.py
@@ -0,0 +1,37 @@
+import os
+import shutil
+import tempfile
+
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+
+
+class BaseLeapTest(unittest.TestCase):
+
+ __name__ = "leap_test"
+
+ @classmethod
+ def setUpClass(cls):
+ cls.old_path = os.environ['PATH']
+ cls.tempdir = tempfile.mkdtemp()
+ bin_tdir = os.path.join(
+ cls.tempdir,
+ 'bin')
+ os.environ["PATH"] = bin_tdir
+
+ @classmethod
+ def tearDownClass(cls):
+ os.environ["PATH"] = cls.old_path
+ shutil.rmtree(cls.tempdir)
+
+ def setUp(self):
+ raise NotImplementedError("abstract base class")
+
+ def tearDown(self):
+ raise NotImplementedError("abstract base class")
+
+
+if __name__ == "__main__":
+ unittest.main()