summaryrefslogtreecommitdiff
path: root/src/leap/testing
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/testing')
-rw-r--r--src/leap/testing/basetest.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/leap/testing/basetest.py b/src/leap/testing/basetest.py
index ccf1a76f..a55b0525 100644
--- a/src/leap/testing/basetest.py
+++ b/src/leap/testing/basetest.py
@@ -1,4 +1,5 @@
import os
+import platform
import shutil
import tempfile
@@ -7,6 +8,10 @@ try:
except ImportError:
import unittest
+from leap.base.config import get_username, get_groupname
+
+_system = platform.system()
+
class BaseLeapTest(unittest.TestCase):
@@ -26,12 +31,32 @@ class BaseLeapTest(unittest.TestCase):
os.environ["PATH"] = cls.old_path
shutil.rmtree(cls.tempdir)
+ # you have to override these methods
+ # this way we ensure we did not put anything
+ # here that you can forget to call.
+
def setUp(self):
raise NotImplementedError("abstract base class")
def tearDown(self):
raise NotImplementedError("abstract base class")
+ #
+ # helper methods
+ #
+
+ def get_tempfile(self, filename):
+ return os.path.join(self.tempdir, filename)
+
+ def get_username(self):
+ return get_username()
+
+ def get_groupname(self):
+ return get_groupname()
-if __name__ == "__main__":
- unittest.main()
+ def _missing_test_for_plat(self, do_raise=False):
+ if do_raise:
+ raise NotImplementedError(
+ "This test is not implemented "
+ "for the running platform: %s" %
+ _system)