本文整理匯總了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