summaryrefslogtreecommitdiffstats
path: root/Lib/doctest.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2012-11-21 20:09:21 (GMT)
committerR David Murray <rdmurray@bitdance.com>2012-11-21 20:09:21 (GMT)
commit5a9d7061236991f671beb0ac4d298e9b79ce6f10 (patch)
tree13b8a1d0c3876c6bdba6f354fc3ee1e47488769c /Lib/doctest.py
parent90d3352da7094fd8074207cc630cf220ad0ce64e (diff)
downloadcpython-5a9d7061236991f671beb0ac4d298e9b79ce6f10.zip
cpython-5a9d7061236991f671beb0ac4d298e9b79ce6f10.tar.gz
cpython-5a9d7061236991f671beb0ac4d298e9b79ce6f10.tar.bz2
#16522: Add FAIL_FAST flag to doctest.
Patch by me, most of the work (doc and tests) by Daniel Urban.
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r--Lib/doctest.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py
index 3af05fb..16a732d 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -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