[master 1/4] Move non-exec tests into a separate class.

David Shea dshea at redhat.com
Fri Aug 8 19:32:47 UTC 2014


Most of RunProgramTests had little to do with running programs, which
made it kind of confusing. Also put the module varaibles modified in
vt_activate_test back the way it found them so that it doesn't have to
run before exec_with_redirect_test.
---
 tests/pyanaconda_tests/iutil_test.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/tests/pyanaconda_tests/iutil_test.py b/tests/pyanaconda_tests/iutil_test.py
index ac4fb76..a782c36 100644
--- a/tests/pyanaconda_tests/iutil_test.py
+++ b/tests/pyanaconda_tests/iutil_test.py
@@ -106,6 +106,7 @@ class RunProgramTests(unittest.TestCase):
         self.assertIsInstance(iutil.execReadlines("true", []),
                               types.GeneratorType)
 
+class MiscTests(unittest.TestCase):
     def get_dir_size_test(self):
         """Test the getDirSize."""
 
@@ -219,11 +220,16 @@ class RunProgramTests(unittest.TestCase):
         def raise_os_error(*args, **kwargs):
             raise OSError
 
-        # chvt does not exist on all platforms
-        # and the function needs to correctly survie that
-        iutil.vtActivate.func_globals['execWithRedirect'] = raise_os_error
+        _execWithRedirect = iutil.vtActivate.func_globals['execWithRedirect']
 
-        self.assertEqual(iutil.vtActivate(2), False)
+        try:
+            # chvt does not exist on all platforms
+            # and the function needs to correctly survie that
+            iutil.vtActivate.func_globals['execWithRedirect'] = raise_os_error
+
+            self.assertEqual(iutil.vtActivate(2), False)
+        finally:
+            iutil.vtActivate.func_globals['execWithRedirect'] = _execWithRedirect
 
     def get_deep_attr_test(self):
         """Test getdeepattr."""
-- 
1.9.3



More information about the anaconda-patches mailing list