[test-API PATCH 1/3] cleanup:make clean function optional

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



    The patch make the writing of clean function optional
    If a testcase makes testing environment dirty after running, it
    must write a CASENAME_clean function to restore back the
    testing environment, otherwise, the clean function could be omitted
---
 env_clear.py |    9 ++++-----
 proxy.py     |    7 ++++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/env_clear.py b/env_clear.py
index 3efc9be..2e5bcf5 100644
--- a/env_clear.py
+++ b/env_clear.py
@@ -30,7 +30,7 @@ class EnvClear(object):
         self.loglevel = loglevel
 
         mapper_obj = mapper.Mapper(activity)
-        clean_pkg_casename_func = mapper_obj.clean_package_casename_func_map()
+        clean_pkg_casename_func = mapper_obj.module_casename_cleanfunc_map()
 
         self.cases_ref_names = []
         for case in clean_pkg_casename_func:
@@ -47,7 +47,7 @@ class EnvClear(object):
         return retflag
 
     def env_clear(self):
-        """ Run each clearing function with the corresponding arguments """
+        """ Run each clean function with the corresponding arguments """
 
         envlog = log.EnvLog(self.logfile, self.loglevel)
         logger = envlog.env_log()
@@ -60,8 +60,7 @@ class EnvClear(object):
             case_params = self.cases_params_list[i]
 
             case_params['logger'] = logger
-            self.cases_clearfunc_ref_dict[case_ref_name](case_params)
-
-        del envlog
+            if self.cases_clearfunc_ref_dict.has_key(case_ref_name):
+                self.cases_clearfunc_ref_dict[case_ref_name](case_params)
 
         return 0
diff --git a/proxy.py b/proxy.py
index 3c4cd63..fdbffd9 100644
--- a/proxy.py
+++ b/proxy.py
@@ -85,12 +85,13 @@ class Proxy(object):
             var_func_names = dir(casemod_ref)
 
             key = module + ':' + casename + ':' + func
+
+            # the clean function is optional, we get its reference
+            # only if it exists in testcases
             if func in var_func_names:
                 func_ref = getattr(casemod_ref, func)
                 func_dict[key] = func_ref
-            else:
-                raise exception.TestCaseError("clean function not found in %s" % \
-                                              (func, testcase_name))
+
         return func_dict
 
     def get_params_variables(self):
-- 
1.7.7.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]