本文整理汇总了Python中HTMLTestRunner.stdout_redirector方法的典型用法代码示例。如果您正苦于以下问题:Python HTMLTestRunner.stdout_redirector方法的具体用法?Python HTMLTestRunner.stdout_redirector怎么用?Python HTMLTestRunner.stdout_redirector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLTestRunner
的用法示例。
在下文中一共展示了HTMLTestRunner.stdout_redirector方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startTest
# 需要导入模块: import HTMLTestRunner [as 别名]
# 或者: from HTMLTestRunner import stdout_redirector [as 别名]
def startTest(self, test):
testMethod = getattr(test, test._testMethodName)
if not (getattr(test.__class__, "__unittest_skip__", False) or
getattr(testMethod, "__unittest_skip__", False)):
logging.info('******************************')
logging.info(test.id().split('.')[-1])
logging.info('******************************')
TestResult.startTest(self, test)
# just one buffer for both stdout and stderr
self.outputBuffer = StringIO.StringIO()
stdout_redirector.testStarted = True
stdout_redirector.fp = self.outputBuffer
stderr_redirector.fp = self.outputBuffer
self.stdout0 = sys.stdout
self.stderr0 = sys.stderr
sys.stdout = stdout_redirector
sys.stderr = stderr_redirector
if xunitReport:
self.xunit.beforeTest(test)
示例2: complete_output
# 需要导入模块: import HTMLTestRunner [as 别名]
# 或者: from HTMLTestRunner import stdout_redirector [as 别名]
def complete_output(self):
"""
Disconnect output redirection and return buffer.
Safe to call multiple times.
"""
if self.stdout0:
sys.stdout = self.stdout0
sys.stderr = self.stderr0
self.stdout0 = None
self.stderr0 = None
stdout_redirector.testStarted = False
try:
output = self.outputBuffer.getvalue()
except:
# failed when outputBuffer hasn't been created
# e.g error is reported in SetUpClass and startTest hasn't been called yet
output = ""
return output
示例3: startTest
# 需要导入模块: import HTMLTestRunner [as 别名]
# 或者: from HTMLTestRunner import stdout_redirector [as 别名]
def startTest(self, test):
TestResult.startTest(self, test)
# just one buffer for both stdout and stderr
self.outputBuffer = io.StringIO()
stdout_redirector.fp = self.outputBuffer
stderr_redirector.fp = self.outputBuffer
self.stdout0 = sys.stdout
self.stderr0 = sys.stderr
sys.stdout = stdout_redirector
sys.stderr = stderr_redirector
示例4: startTest
# 需要导入模块: import HTMLTestRunner [as 别名]
# 或者: from HTMLTestRunner import stdout_redirector [as 别名]
def startTest(self, test):
TestResult.startTest(self, test)
# just one buffer for both stdout and stderr
self.outputBuffer = StringIO.StringIO()
stdout_redirector.fp = self.outputBuffer
stderr_redirector.fp = self.outputBuffer
self.stdout0 = sys.stdout
self.stderr0 = sys.stderr
sys.stdout = stdout_redirector
sys.stderr = stderr_redirector