本文整理汇总了Python中TestCase.TestCase.suite方法的典型用法代码示例。如果您正苦于以下问题:Python TestCase.suite方法的具体用法?Python TestCase.suite怎么用?Python TestCase.suite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestCase.TestCase
的用法示例。
在下文中一共展示了TestCase.suite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ParseFileType
# 需要导入模块: from TestCase import TestCase [as 别名]
# 或者: from TestCase.TestCase import suite [as 别名]
def ParseFileType(self, file_name, file_type):
Log.Log(Log.DEBUG, "Parsing " + file_type + " file: ")
print(str(file_name))
ret = ERROR
ts = None
tc = None
suite_regexp = None
case_regexp_list = None
if file_type == TestGlobal.GTEST_TYPE:
suite_regexp = GTEST_SUITE_REGEXP
case_regexp_list = GTEST_CASE_REGEXP_LIST
elif file_type == TestGlobal.JUNIT_TYPE:
suite_regexp = JUNIT_SUITE_REGEXP
case_regexp_list = JUNIT_CASE_REGEXP_LIST
elif file_type == TestGlobal.CUNIT_TYPE:
suite_regexp = CUNIT_SUITE_REGEXP
case_regexp_list = CUNIT_CASE_REGEXP_LIST
# TODO Implement other framework
else:
Log.Log(Log.ERROR, "Unknown file type in ParseFileType!")
return ERROR
f = open(file_name)
content = f.read()
f.close()
# Parsing Suite description
for m in re.finditer(suite_regexp, content, re.MULTILINE|re.DOTALL):
if m != None and ts == None:
ts = TestSuite()
# Log.Log(Log.DEBUG, "Suite: " + TestGlobal.StripCommentStars(m.group(1)))
ret = ts.ParseHeader(TestGlobal.StripCommentStars(m.group(1)))
if ret != OK:
break
# Verify
suite_name = os.path.basename(file_name).split('.')[0]
if ts.suite != suite_name:
Log.Log(Log.WARNING, "Some suite comment inconsistencies are detected in " + os.path.basename(file_name) + ": " + ts.suite + " != " + suite_name)
else:
ret = ERROR
break
if ret != OK:
Log.Log(Log.ERROR, "Invalid suite format in " + os.path.basename(file_name))
return ret
ts.type = file_type
ts.test_case_dict = dict()
# Parsing Case descriptions
ret = ERROR
for case_regexp in case_regexp_list:
for m in re.finditer(case_regexp, content, re.MULTILINE|re.DOTALL):
if m != None:
tc = TestCase()
tc.suite = ts # Add a backward link to the suite as well
tc.case = m.group(2)
# Log.Log(Log.DEBUG, "Case: " + TestGlobal.StripCommentStars(m.group(1)))
ret = tc.ParseHeader(TestGlobal.StripCommentStars(m.group(1)))
if ret == OK:
# Add tc into ts
if tc.case in ts.test_case_dict:
Log.Log(Log.WARNING, "Test case " + tc.case + " duplicated in " + ts.suite + ". Test case ignored!")
else:
ts.test_case_dict[tc.case] = tc
else:
Log.Log(Log.WARNING, "Impossible to parse header: " + m.group(1))
ret = OK # Just continue
else:
Log.Log(Log.WARNING, "No test cases in test suite!")
ret = ERROR
break
# Add ts to class dictionary
if not self.test_suite_dict:
self.test_suite_dict = dict()
if ts.suite in self.test_suite_dict:
Log.Log(Log.WARNING, "Test suite " + ts.suite + " duplicated. Test case ignored!")
else:
self.test_suite_dict[ts.suite] = ts
if ret == OK:
print("OK")
else:
print("ERROR")
return ret