本文整理匯總了Python中test.test_support.get_original_stdout方法的典型用法代碼示例。如果您正苦於以下問題:Python test_support.get_original_stdout方法的具體用法?Python test_support.get_original_stdout怎麽用?Python test_support.get_original_stdout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類test.test_support
的用法示例。
在下文中一共展示了test_support.get_original_stdout方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_recursions_1
# 需要導入模塊: from test import test_support [as 別名]
# 或者: from test.test_support import get_original_stdout [as 別名]
def test_recursions_1(self):
# Testing recursion checks ...
class Letter(str):
def __new__(cls, letter):
if letter == 'EPS':
return str.__new__(cls)
return str.__new__(cls, letter)
def __str__(self):
if not self:
return 'EPS'
return self
# sys.stdout needs to be the original to trigger the recursion bug
test_stdout = sys.stdout
sys.stdout = test_support.get_original_stdout()
try:
# nothing should actually be printed, this should raise an exception
print Letter('w')
except RuntimeError:
pass
else:
self.fail("expected a RuntimeError for print recursion")
finally:
sys.stdout = test_stdout