[Python-checkins] python/dist/src/Lib doctest.py,1.86,1.87
edloper at users.sourceforge.net
edloper at users.sourceforge.net
Thu Aug 26 03:41:53 CEST 2004
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19362/dist/src/Lib
Modified Files:
doctest.py
Log Message:
Renamed UNIFIED_DIFF->REPORT_UDIFF; CONTEXT_DIFF->REPORT_CDIFF; and
NDIFF_DIFF->REPORT_NDIFF. This establishes the naming convention that
all reporting options should begin with "REPORT_" (since reporting
options are a different class from output comparison options; but they
are both set in optionflags).
Index: doctest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -d -r1.86 -r1.87
--- doctest.py 26 Aug 2004 01:31:56 -0000 1.86
+++ doctest.py 26 Aug 2004 01:41:51 -0000 1.87
@@ -176,9 +176,9 @@
'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_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 @@
# 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 @@
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 @@
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 @@
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
More information about the Python-checkins
mailing list