本文整理汇总了Python中doctest.DocTestRunner.report_start方法的典型用法代码示例。如果您正苦于以下问题:Python DocTestRunner.report_start方法的具体用法?Python DocTestRunner.report_start怎么用?Python DocTestRunner.report_start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类doctest.DocTestRunner
的用法示例。
在下文中一共展示了DocTestRunner.report_start方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: report_start
# 需要导入模块: from doctest import DocTestRunner [as 别名]
# 或者: from doctest.DocTestRunner import report_start [as 别名]
def report_start(self, out, test, example):
if 1 <= self._verbosity <= 2:
src = example.source.split('\n')[0]
if len(src) > 60: src = src[:57]+'...'
lineno = test.lineno + example.lineno + 1
if self._verbosity == 1:
if self._stderr_term.CLEAR_LINE:
sys.__stderr__.write(self._stderr_term.CLEAR_LINE)
else:
sys.__stderr__.write('\n')
sys.__stderr__.write('%s [Line %s] %s%s' %
(self._stderr_term.BOLD, lineno,
self._stderr_term.NORMAL, src))
if self._verbosity == 2:
sys.__stderr__.write('\n')
else:
DocTestRunner.report_start(self, out, test, example)
sys.__stdout__.flush()
self._current_test = (test, example)
# Total hack warning: This munges the original source to
# catch any keyboard interrupts, and turn them into special
# ValueError interrupts.
example.original_source = example.source
if self._kbinterrupt_continue:
example.source = ('try:\n%sexcept KeyboardInterrupt:\n '
'raise ValueError("KEYBOARD-INTERRUPT")\n' %
doctest._indent(example.source))