diff options
author | Tomás Touceda <chiiph@leap.se> | 2013-06-28 14:25:19 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2013-06-28 14:25:19 -0300 |
commit | 5b975799ce9b7a6e0a88be4bcb48bdfb90800bb3 (patch) | |
tree | bda674a79b1aeccb37b67609517bc4761db7ae07 /src/leap/testing/basetest.py | |
parent | 9cea9c8a34343f8792d65b96f93ae22bd8685878 (diff) | |
parent | c088a1544a5f7a51359d2802019c0740aab0cc5b (diff) |
Merge branch 'release-0.2.2'0.2.2
Diffstat (limited to 'src/leap/testing/basetest.py')
-rw-r--r-- | src/leap/testing/basetest.py | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/src/leap/testing/basetest.py b/src/leap/testing/basetest.py deleted file mode 100644 index 3186e1eb..00000000 --- a/src/leap/testing/basetest.py +++ /dev/null @@ -1,85 +0,0 @@ -import os -import platform -import shutil -import tempfile - -try: - import unittest2 as unittest -except ImportError: - import unittest - -from leap.base.config import get_username, get_groupname -from leap.util.fileutil import mkdir_p, check_and_fix_urw_only - -_system = platform.system() - - -class BaseLeapTest(unittest.TestCase): - - __name__ = "leap_test" - - @classmethod - def setUpClass(cls): - cls.old_path = os.environ['PATH'] - cls.old_home = os.environ['HOME'] - cls.tempdir = tempfile.mkdtemp(prefix="leap_tests-") - cls.home = cls.tempdir - bin_tdir = os.path.join( - cls.tempdir, - 'bin') - os.environ["PATH"] = bin_tdir - os.environ["HOME"] = cls.tempdir - - @classmethod - def tearDownClass(cls): - os.environ["PATH"] = cls.old_path - os.environ["HOME"] = cls.old_home - # safety check - assert cls.tempdir.startswith('/tmp/leap_tests-') - 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() - - 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) - - def touch(self, filepath): - folder, filename = os.path.split(filepath) - if not os.path.isdir(folder): - mkdir_p(folder) - # XXX should move to test_basetest - self.assertTrue(os.path.isdir(folder)) - - with open(filepath, 'w') as fp: - fp.write(' ') - - # XXX should move to test_basetest - self.assertTrue(os.path.isfile(filepath)) - - def chmod600(self, filepath): - check_and_fix_urw_only(filepath) |