本文整理汇总了Python中TestCase.TestCase.set_status方法的典型用法代码示例。如果您正苦于以下问题:Python TestCase.set_status方法的具体用法?Python TestCase.set_status怎么用?Python TestCase.set_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestCase.TestCase
的用法示例。
在下文中一共展示了TestCase.set_status方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_post_suite_execute_work
# 需要导入模块: from TestCase import TestCase [as 别名]
# 或者: from TestCase.TestCase import set_status [as 别名]
def do_post_suite_execute_work(test_run,suite) :
dprint(1,"* Entering do_post_suite_execute_work")
# set the stop time as now
suite.set_end_time()
# unset the environment variables
do_env_vars(test_run.env_var_list,"unset")
# parse the output log
if os.path.getsize(suite.output_log) <= 0 :
# file either does not exist or has no content
suite.set_status("INDETERMINATE")
else :
# parse the log to find results
# open output file
try :
dprint(3," * Opening file " + suite.output_log)
log = open(suite.output_log,'r')
except IOError,e :
print "Problem opening file %s" % (suite.output_log)
print e[0], e[1]
# end try
for line in log :
# see if there is a TC_RESULT line in the output
if "TC_RESULT" in line :
suite.tc_count = suite.tc_count + 1
# get a new TestCase object; temporarily name it "testN"
temp_name = "test%d" % (suite.tc_count)
tc = TestCase(temp_name)
tc.run_order = suite.tc_count
if re.search(r'TC_RESULT\s*=\s*PASS',line) :
suite.tc_pass = suite.tc_pass + 1
tc.set_status("PASS")
dprint(3," * TC status is PASS")
elif re.search(r'TC_RESULT\s*=\s*EXPECTED_TO_FAIL',line) :
suite.tc_expected_to_fail = suite.tc_expected_to_fail + 1
tc.set_status("EXPECTED_TO_FAIL")
dprint(3," * TC status is EXPECTED_TO_FAIL")
elif re.search(r'TC_RESULT\s*=\s*FAIL',line) :
suite.tc_fail = suite.tc_fail + 1
tc.set_status("FAIL")
dprint(3," * TC status is FAIL")
else :
# a line containing TC_RESULT was found, but it is not a known status
suite.tc_indeterminate = suite.tc_indeterminate + 1
tc.set_status("INDETERMINATE")
dprint(3," * TC status is INDETERMINATE")
# end if
# there should be a name included with the result
parsed = re.split('TC_NAME\s*=',line)
if len(parsed) > 1 :
# there's a name; take the first word as the TC name
remaining = parsed[1]
parsed = remaining.rsplit(None)
if len(parsed) > 0 and parsed[0] != "" :
# name found
tc.name = parsed[0]
dprint(3," * TC name found: " + tc.name)
else :
# even though 'TC_NAME=' found, no name given, leave the temporary on in place
dprint(3," * TC_NAME found, but no name given")
# end if
else :
# no name given, leave the temporary one in place
dprint(3," * No TC_NAME found")
# end if
# add the TC object to the suite's list
suite.test_case_list.append(tc)
# end if
# end for
# close the file
log.close()