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