本文整理汇总了Python中unittest.result.TestResult.startTest方法的典型用法代码示例。如果您正苦于以下问题:Python TestResult.startTest方法的具体用法?Python TestResult.startTest怎么用?Python TestResult.startTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.result.TestResult
的用法示例。
在下文中一共展示了TestResult.startTest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startTest
# 需要导入模块: from unittest.result import TestResult [as 别名]
# 或者: from unittest.result.TestResult import startTest [as 别名]
def startTest(self, test):
"""
Starting the test we redirect the output to not show in the screen
"""
TestResult.startTest(self, test)
# Start a new output text result
self.output = StringIO()
self._stdout.fp = self.output
self._stderr.fp = self.output
# Conserve the original output
self.org_stderr = sys.stderr
self.org_stdout = sys.stdout
sys.stdout = self._stdout
sys.stderr = self._stderr
# Define the structure
self.class_name = test.__class__.__name__
self.method_name = test._testMethodName
if self.class_name not in self.result["class_list"].keys():
class_doc = [] if test.__doc__ is None else \
[ item.strip() for item in test.__doc__.splitlines() \
if item.strip() != "" ]
self.result["class_list"][self.class_name] = {
"module": test.__module__,
"description": class_doc,
"success_count": 0,
"error_count": 0,
"failure_count": 0,
"skip_count": 0,
"expected_failure_count": 0,
"unexpected_success_count": 0,
"methods": {}
}
if self.method_name not in \
self.result["class_list"][self.class_name]["methods"].keys():
method_doc = [""] if test._testMethodDoc is None else \
[ item.strip() for item in \
test._testMethodDoc.splitlines() if item.strip() != ""
]
self.result["class_list"][self.class_name]["methods"][self.method_name] = \
{
"started": datetime.now(),
"status": None,
"stopped": None,
"message": "",
"error": None,
"description": method_doc
}
示例2: startTest
# 需要导入模块: from unittest.result import TestResult [as 别名]
# 或者: from unittest.result.TestResult import startTest [as 别名]
def startTest(self, test: TestCase) -> None:
TestResult.startTest(self, test)
self.stream.writeln("Running {}".format(full_test_name(test)))
self.stream.flush()