summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/lib/libdoctest.tex10
-rw-r--r--Lib/doctest.py32
-rw-r--r--Lib/test/test_doctest.py14
3 files changed, 28 insertions, 28 deletions
diff --git a/Doc/lib/libdoctest.tex b/Doc/lib/libdoctest.tex
index 0db5d5d..dca79f7 100644
--- a/Doc/lib/libdoctest.tex
+++ b/Doc/lib/libdoctest.tex
@@ -344,17 +344,17 @@ can also be used in doctest directives (see below).
is prone to in regular expressions.
\end{datadesc}
-\begin{datadesc}{UNIFIED_DIFF}
+\begin{datadesc}{REPORT_UDIFF}
When specified, failures that involve multi-line expected and
actual outputs are displayed using a unified diff.
\end{datadesc}
-\begin{datadesc}{CONTEXT_DIFF}
+\begin{datadesc}{REPORT_CDIFF}
When specified, failures that involve multi-line expected and
actual outputs will be displayed using a context diff.
\end{datadesc}
-\begin{datadesc}{NDIFF_DIFF}
+\begin{datadesc}{REPORT_NDIFF}
When specified, differences are computed by \code{difflib.Differ},
using the same algorithm as the popular \file{ndiff.py} utility.
This is the only method that marks differences within lines as
@@ -421,8 +421,8 @@ can be useful.
\versionchanged[Constants \constant{DONT_ACCEPT_BLANKLINE},
\constant{NORMALIZE_WHITESPACE}, \constant{ELLIPSIS},
- \constant{UNIFIED_DIFF}, \constant{CONTEXT_DIFF}, and
- \constant{NDIFF_DIFF}
+ \constant{REPORT_UDIFF}, \constant{REPORT_CDIFF}, and
+ \constant{REPORT_NDIFF}
were added; by default \code{<BLANKLINE>} in expected output
matches an empty line in actual output; and doctest directives
were added]{2.4}
diff --git a/Lib/doctest.py b/Lib/doctest.py
index 9a88b7a..5e83c18 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -176,9 +176,9 @@ __all__ = [
'DONT_ACCEPT_BLANKLINE',
'NORMALIZE_WHITESPACE',
'ELLIPSIS',
- 'UNIFIED_DIFF',
- 'CONTEXT_DIFF',
- 'NDIFF_DIFF',
+ 'REPORT_UDIFF',
+ 'REPORT_CDIFF',
+ 'REPORT_NDIFF',
# 1. Utility Functions
'is_private',
# 2. Example & DocTest
@@ -257,9 +257,9 @@ DONT_ACCEPT_TRUE_FOR_1 = register_optionflag('DONT_ACCEPT_TRUE_FOR_1')
DONT_ACCEPT_BLANKLINE = register_optionflag('DONT_ACCEPT_BLANKLINE')
NORMALIZE_WHITESPACE = register_optionflag('NORMALIZE_WHITESPACE')
ELLIPSIS = register_optionflag('ELLIPSIS')
-UNIFIED_DIFF = register_optionflag('UNIFIED_DIFF')
-CONTEXT_DIFF = register_optionflag('CONTEXT_DIFF')
-NDIFF_DIFF = register_optionflag('NDIFF_DIFF')
+REPORT_UDIFF = register_optionflag('REPORT_UDIFF')
+REPORT_CDIFF = register_optionflag('REPORT_CDIFF')
+REPORT_NDIFF = register_optionflag('REPORT_NDIFF')
# Special string markers for use in `want` strings:
BLANKLINE_MARKER = '<BLANKLINE>'
@@ -1582,9 +1582,9 @@ class OutputChecker:
# Should we do a fancy diff?
def _do_a_fancy_diff(self, want, got, optionflags):
# Not unless they asked for a fancy diff.
- if not optionflags & (UNIFIED_DIFF |
- CONTEXT_DIFF |
- NDIFF_DIFF):
+ if not optionflags & (REPORT_UDIFF |
+ REPORT_CDIFF |
+ REPORT_NDIFF):
return False
# If expected output uses ellipsis, a meaningful fancy diff is
# too hard.
@@ -1592,7 +1592,7 @@ class OutputChecker:
return False
# ndiff does intraline difference marking, so can be useful even
# for 1-line inputs.
- if optionflags & NDIFF_DIFF:
+ if optionflags & REPORT_NDIFF:
return True
# The other diff types need at least a few lines to be helpful.
return want.count('\n') > 2 and got.count('\n') > 2
@@ -1617,15 +1617,15 @@ class OutputChecker:
want_lines = [l+'\n' for l in want.split('\n')]
got_lines = [l+'\n' for l in got.split('\n')]
# Use difflib to find their differences.
- if optionflags & UNIFIED_DIFF:
+ if optionflags & REPORT_UDIFF:
diff = difflib.unified_diff(want_lines, got_lines, n=2)
diff = list(diff)[2:] # strip the diff header
kind = 'unified diff with -expected +actual'
- elif optionflags & CONTEXT_DIFF:
+ elif optionflags & REPORT_CDIFF:
diff = difflib.context_diff(want_lines, got_lines, n=2)
diff = list(diff)[2:] # strip the diff header
kind = 'context diff with expected followed by actual'
- elif optionflags & NDIFF_DIFF:
+ elif optionflags & REPORT_NDIFF:
engine = difflib.Differ(charjunk=difflib.IS_CHARACTER_JUNK)
diff = list(engine.compare(want_lines, got_lines))
kind = 'ndiff with -expected +actual'
@@ -1839,9 +1839,9 @@ def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None,
DONT_ACCEPT_BLANKLINE
NORMALIZE_WHITESPACE
ELLIPSIS
- UNIFIED_DIFF
- CONTEXT_DIFF
- NDIFF_DIFF
+ REPORT_UDIFF
+ REPORT_CDIFF
+ REPORT_NDIFF
Optional keyword arg "raise_on_error" raises an exception on the
first unexpected exception or failure. This allows failures to be
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index 29c3ec2..d683051 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -923,7 +923,7 @@ output to match any substring in the actual output:
... # doctest: +NORMALIZE_WHITESPACE
[0, 1, ..., 18, 19]
-The UNIFIED_DIFF flag causes failures that involve multi-line expected
+The REPORT_UDIFF flag causes failures that involve multi-line expected
and actual outputs to be displayed using a unified diff:
>>> def f(x):
@@ -965,7 +965,7 @@ and actual outputs to be displayed using a unified diff:
>>> # With the flag:
>>> test = doctest.DocTestFinder().find(f)[0]
- >>> flags = doctest.UNIFIED_DIFF
+ >>> flags = doctest.REPORT_UDIFF
>>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
**********************************************************************
Line 2, in f
@@ -985,12 +985,12 @@ and actual outputs to be displayed using a unified diff:
<BLANKLINE>
(1, 1)
-The CONTEXT_DIFF flag causes failures that involve multi-line expected
+The REPORT_CDIFF flag causes failures that involve multi-line expected
and actual outputs to be displayed using a context diff:
- >>> # Reuse f() from the UNIFIED_DIFF example, above.
+ >>> # Reuse f() from the REPORT_UDIFF example, above.
>>> test = doctest.DocTestFinder().find(f)[0]
- >>> flags = doctest.CONTEXT_DIFF
+ >>> flags = doctest.REPORT_CDIFF
>>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
**********************************************************************
Line 2, in f
@@ -1019,7 +1019,7 @@ and actual outputs to be displayed using a context diff:
(1, 1)
-The NDIFF_DIFF flag causes failures to use the difflib.Differ algorithm
+The REPORT_NDIFF flag causes failures to use the difflib.Differ algorithm
used by the popular ndiff.py utility. This does intraline difference
marking, as well as interline differences.
@@ -1029,7 +1029,7 @@ marking, as well as interline differences.
... a b c d e f g h i j k 1 m
... '''
>>> test = doctest.DocTestFinder().find(f)[0]
- >>> flags = doctest.NDIFF_DIFF
+ >>> flags = doctest.REPORT_NDIFF
>>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
**********************************************************************
Line 2, in f