[test-API PATCH 2/3] improvement on comments function name and destruct logger handlers

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

 



    generator.py
    libvirt-test-api.py
    mapper.py
    utils/log.py: add __del__() to destruct logger handlers when
                  it go out of context
---
 generator.py        |    2 +-
 libvirt-test-api.py |    1 +
 mapper.py           |   14 +++++++++-----
 utils/log.py        |    6 ++++++
 4 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/generator.py b/generator.py
index 0c3aec4..62b0d66 100644
--- a/generator.py
+++ b/generator.py
@@ -61,7 +61,7 @@ class FuncGen(object):
         self.env = env_parser.Envparser("env.cfg")
 
         mapper_obj = mapper.Mapper(activity)
-        pkg_casename_func = mapper_obj.package_casename_func_map()
+        pkg_casename_func = mapper_obj.module_casename_func_map()
 
         for test_procedure in pkg_casename_func:
             log_xml_parser.add_testprocedure_xml(testrunid,
diff --git a/libvirt-test-api.py b/libvirt-test-api.py
index 877104c..c171276 100644
--- a/libvirt-test-api.py
+++ b/libvirt-test-api.py
@@ -205,6 +205,7 @@ class Main(object):
                     logname = log.Log.get_log_name()
                     logfile = os.path.join('log/%s' % testrunid, logname)
                     env_clear.EnvClear(cases_clearfunc_ref_dict, activity, logfile, self.loglevel)()
+                print "Done"
             elif options_list[0]['options']["cleanup"] == "disable":
                 pass
             else:
diff --git a/mapper.py b/mapper.py
index f0b675a..c2c44da 100644
--- a/mapper.py
+++ b/mapper.py
@@ -22,10 +22,12 @@ import copy
 class Mapper(object):
 
     def __init__(self, testcases_list):
-        self.testcases_list = copy.deepcopy(testcases_list)
+        self.testcases_list = testcases_list
 
-    def package_casename_func_map(self):
-        """ Remove the package information to form a new dictionary """
+    def module_casename_func_map(self):
+        """ generate a new list of dictionary
+            change key from module:casename to module:casename:func
+        """
         tripped_cases_list = []
         prev_testcasename = ''
         prev_testcases_params = ''
@@ -56,8 +58,10 @@ class Mapper(object):
 
         return tripped_cases_list
 
-    def clean_package_casename_func_map(self):
-        """get testcase function maping without cleaning ones """
+    def module_casename_cleanfunc_map(self):
+        """generate a new data format
+           keys of dictionay are of module:casename:casename_clean
+        """
         tripped_cases_list = []
         for testcase in self.testcases_list:
             tripped_case = {}
diff --git a/utils/log.py b/utils/log.py
index bd6f816..b146956 100644
--- a/utils/log.py
+++ b/utils/log.py
@@ -56,6 +56,9 @@ class CaseLog(Log):
         self.logger.setLevel(logging.DEBUG)
         super(CaseLog, self).__init__(logname, loglevel)
 
+    def __del__(self):
+        self.logger.handlers = []
+
     def case_log(self):
         """Initialize log file"""
         fmt = {'file_formatter':
@@ -94,6 +97,9 @@ class EnvLog(Log):
         self.logger.setLevel(logging.DEBUG)
         super(EnvLog, self).__init__(logname, loglevel)
 
+    def __del__(self):
+        self.logger.handlers = []
+
     def env_log(self):
         """Initialize log file"""
         fmt = {'file_formatter':'%(message)s',
-- 
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]