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