本文整理汇总了Python中testfixtures.LogCapture.__exit__方法的典型用法代码示例。如果您正苦于以下问题:Python LogCapture.__exit__方法的具体用法?Python LogCapture.__exit__怎么用?Python LogCapture.__exit__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testfixtures.LogCapture
的用法示例。
在下文中一共展示了LogCapture.__exit__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ShowBearsTest
# 需要导入模块: from testfixtures import LogCapture [as 别名]
# 或者: from testfixtures.LogCapture import __exit__ [as 别名]
class ShowBearsTest(unittest.TestCase):
def setUp(self):
self.console_printer = ConsolePrinter(print_colored=False)
self.logs = LogCapture()
self.logs.__enter__()
deprecation_messages = [('root',
'WARNING',
'show_description parameter is deprecated'),
('root',
'WARNING',
'show_params parameter is deprecated')]
def tearDown(self):
self.logs.__exit__(None, None, None)
def test_show_bear_minimal(self):
with retrieve_stdout() as stdout:
show_bear(
SomelocalBear, False, False, self.console_printer)
self.assertEqual(stdout.getvalue(), 'SomelocalBear\n')
self.logs.check(*self.deprecation_messages)
def test_show_bear_desc_only(self):
with retrieve_stdout() as stdout:
show_bear(
SomelocalBear, True, False, self.console_printer)
self.assertEqual(
stdout.getvalue(),
'SomelocalBear\n Some local-bear Description.\n\n')
self.logs.check(*self.deprecation_messages)
def test_show_bear_details_only(self):
with retrieve_stdout() as stdout:
show_bear(
SomelocalBear, False, True, self.console_printer)
self.assertEqual(stdout.getvalue(),
'SomelocalBear\n'
' The bear does not provide information about '
'which languages it can analyze.\n\n'
' No needed settings.\n\n'
' No optional settings.\n\n'
' This bear does not provide information about '
'what categories it can detect.\n\n'
' This bear cannot fix issues or does not '
'provide information about what categories it '
'can fix.\n\n Path:\n ' +
repr(SomelocalBear.source_location) + '\n\n')
self.logs.check(*self.deprecation_messages)
def test_show_bear_long_without_content(self):
with retrieve_stdout() as stdout:
show_bear(
SomelocalBear, True, True, self.console_printer)
self.assertEqual(stdout.getvalue(),
'SomelocalBear\n'
' Some local-bear Description.\n\n'
' The bear does not provide information about '
'which languages it can analyze.\n\n'
' No needed settings.\n\n'
' No optional settings.\n\n'
' This bear does not provide information about '
'what categories it can detect.\n\n'
' This bear cannot fix issues or does not '
'provide information about what categories it '
'can fix.\n\n Path:\n ' +
repr(SomelocalBear.source_location) + '\n\n')
self.logs.check(*self.deprecation_messages)
def test_show_bear_with_content(self):
with retrieve_stdout() as stdout:
show_bear(TestBear, True, True, self.console_printer)
self.assertEqual(stdout.getvalue(),
'TestBear\n'
' Test bear Description.\n\n'
' Supported languages:\n'
' * F#\n'
' * Shakespearean Programming Language\n\n'
' Needed Settings:\n'
' * setting1: Required Setting.\n\n'
' Optional Settings:\n'
' * setting2: Optional Setting. ('
"Optional, defaults to 'None'."
')\n\n'
' Can detect:\n * Formatting\n\n'
' Can fix:\n * Formatting\n\n Path:\n ' +
repr(TestBear.source_location) + '\n\n')
self.logs.check(*self.deprecation_messages)
def test_show_bear_settings_only(self):
with retrieve_stdout() as stdout:
args = default_arg_parser().parse_args(['--show-settings'])
show_bear(TestBear, False, False, self.console_printer, args)
self.assertEqual(stdout.getvalue(),
#.........这里部分代码省略.........