fix KeyError: 'clean_flag'
[functest.git] / functest / ci / run_tests.py
index b1ab916..2706a80 100755 (executable)
@@ -48,7 +48,7 @@ class BlockingTestFailed(Exception):
     pass
 
 
-class RunTestsParser():
+class RunTestsParser(object):
 
     def __init__(self):
         self.parser = argparse.ArgumentParser()
@@ -143,7 +143,7 @@ def run_test(test, tier_name, testcases=None):
     logger.debug("\n%s" % test)
     source_rc_file()
 
-    if GlobalVariables.CLEAN_FLAG:
+    if test.needs_clean() and GlobalVariables.CLEAN_FLAG:
         generate_os_snapshot()
 
     flags = (" -t %s" % (test_name))
@@ -157,6 +157,7 @@ def run_test(test, tier_name, testcases=None):
             module = importlib.import_module(run_dict['module'])
             cls = getattr(module, run_dict['class'])
             test_case = cls()
+
             try:
                 kwargs = run_dict['args']
                 result = test_case.run(**kwargs)
@@ -164,7 +165,7 @@ def run_test(test, tier_name, testcases=None):
                 result = test_case.run()
             if result == testcase_base.TestcaseBase.EX_OK:
                 if GlobalVariables.REPORT_FLAG:
-                    test_case.publish_report()
+                    test_case.push_to_db()
                 result = test_case.check_criteria()
         except ImportError:
             logger.exception("Cannot import module {}".format(
@@ -179,8 +180,9 @@ def run_test(test, tier_name, testcases=None):
                         cmd, test_name))
         result = ft_utils.execute_command(cmd)
 
-    if GlobalVariables.CLEAN_FLAG:
+    if test.needs_clean() and GlobalVariables.CLEAN_FLAG:
         cleanup()
+
     end = datetime.datetime.now()
     duration = (end - start).seconds
     duration_str = ("%02d:%02d" % divmod(duration, 60))