本文整理汇总了Python中unittest._TextTestResult方法的典型用法代码示例。如果您正苦于以下问题:Python unittest._TextTestResult方法的具体用法?Python unittest._TextTestResult怎么用?Python unittest._TextTestResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest
的用法示例。
在下文中一共展示了unittest._TextTestResult方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addSuccess
# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import _TextTestResult [as 别名]
def addSuccess(self, test):
super(TextTestResult, self).addSuccess(test)
self._process(test, "ok")
示例2: addFailure
# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import _TextTestResult [as 别名]
def addFailure(self, test, err):
super(TextTestResult, self).addFailure(test, err)
self._process(test, "not ok", "FAIL")
# [ ] add structured data about assertion
示例3: addError
# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import _TextTestResult [as 别名]
def addError(self, test, err):
super(TextTestResult, self).addError(test, err)
self._process(test, "not ok", "ERROR")
# [ ] add structured data about exception
示例4: addSkip
# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import _TextTestResult [as 别名]
def addSkip(self, test, reason):
super(TextTestResult, self).addSkip(test, reason)
self._process(test, "ok", directive=(" # SKIP %s" % reason))
示例5: addExpectedFailure
# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import _TextTestResult [as 别名]
def addExpectedFailure(self, test, err):
super(TextTestResult, self).addExpectedFailure(test, err)
self._process(test, "not ok", directive=(" # TODO"))
示例6: run_test_suite
# 需要导入模块: import unittest [as 别名]
# 或者: from unittest import _TextTestResult [as 别名]
def run_test_suite():
def mark_failed():
global failed
failed = True
class _TrackingTextTestResult(unittest._TextTestResult):
def addError(self, test, err):
unittest._TextTestResult.addError(self, test, err)
mark_failed()
def addFailure(self, test, err):
unittest._TextTestResult.addFailure(self, test, err)
mark_failed()
class TrackingTextTestRunner(unittest.TextTestRunner):
def _makeResult(self):
return _TrackingTextTestResult(
self.stream, self.descriptions, self.verbosity)
load_env_file(os.path.abspath(os.getcwd()) + os.sep + "environment.env")
original_cwd = os.path.abspath(os.getcwd())
os.chdir('.%stests%s' % (os.sep, os.sep))
suite = unittest.defaultTestLoader.discover('.', pattern="*.py")
runner = TrackingTextTestRunner(verbosity=2)
runner.run(suite)
os.chdir(original_cwd)
return failed