Extract the environment set up and tear down for tests
authorRuben Pollan <meskio@sindominio.net>
Wed, 3 Dec 2014 15:42:45 +0000 (09:42 -0600)
committerRuben Pollan <meskio@sindominio.net>
Wed, 3 Dec 2014 16:28:19 +0000 (10:28 -0600)
Using trial there is no setUpClass neither tearDownClass, the setting up
of the environment needs to be in an external class to be able to call
it from inhereted classes.

changes/feature-test_env [new file with mode: 0644]
src/leap/common/testing/basetest.py

diff --git a/changes/feature-test_env b/changes/feature-test_env
new file mode 100644 (file)
index 0000000..77614d7
--- /dev/null
@@ -0,0 +1 @@
+- Extract the environment set up and tear down for tests
index 54826d5..3c6fc29 100644 (file)
@@ -40,6 +40,14 @@ class BaseLeapTest(unittest.TestCase):
 
     @classmethod
     def setUpClass(cls):
+        cls.setUpEnv()
+
+    @classmethod
+    def tearDownClass(cls):
+        cls.tearDownEnv()
+
+    @classmethod
+    def setUpEnv(cls):
         """
         Sets up common facilities for testing this TestCase:
         - custom PATH and HOME environmental variables
@@ -57,7 +65,7 @@ class BaseLeapTest(unittest.TestCase):
         os.environ["HOME"] = cls.tempdir
 
     @classmethod
-    def tearDownClass(cls):
+    def tearDownEnv(cls):
         """
         Cleanup common facilities used for testing this TestCase:
         - restores the default PATH and HOME variables