mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
#16522: Add FAIL_FAST flag to doctest.
Patch by me, most of the work (doc and tests) by Daniel Urban.
This commit is contained in:
parent
90d3352da7
commit
5a9d706123
5 changed files with 69 additions and 4 deletions
|
@ -62,6 +62,7 @@ __all__ = [
|
|||
'REPORT_NDIFF',
|
||||
'REPORT_ONLY_FIRST_FAILURE',
|
||||
'REPORTING_FLAGS',
|
||||
'FAIL_FAST',
|
||||
# 1. Utility Functions
|
||||
# 2. Example & DocTest
|
||||
'Example',
|
||||
|
@ -150,11 +151,13 @@ REPORT_UDIFF = register_optionflag('REPORT_UDIFF')
|
|||
REPORT_CDIFF = register_optionflag('REPORT_CDIFF')
|
||||
REPORT_NDIFF = register_optionflag('REPORT_NDIFF')
|
||||
REPORT_ONLY_FIRST_FAILURE = register_optionflag('REPORT_ONLY_FIRST_FAILURE')
|
||||
FAIL_FAST = register_optionflag('FAIL_FAST')
|
||||
|
||||
REPORTING_FLAGS = (REPORT_UDIFF |
|
||||
REPORT_CDIFF |
|
||||
REPORT_NDIFF |
|
||||
REPORT_ONLY_FIRST_FAILURE)
|
||||
REPORT_ONLY_FIRST_FAILURE |
|
||||
FAIL_FAST)
|
||||
|
||||
# Special string markers for use in `want` strings:
|
||||
BLANKLINE_MARKER = '<BLANKLINE>'
|
||||
|
@ -1342,6 +1345,9 @@ class DocTestRunner:
|
|||
else:
|
||||
assert False, ("unknown outcome", outcome)
|
||||
|
||||
if failures and self.optionflags & FAIL_FAST:
|
||||
break
|
||||
|
||||
# Restore the option flags (in case they were modified)
|
||||
self.optionflags = original_optionflags
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue