diff options
author | Tim Peters <tim.peters@gmail.com> | 2004-08-26 05:21:59 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2004-08-26 05:21:59 (GMT) |
commit | 5b799c1f3d1e96e2d45737bed95a149d356ad5de (patch) | |
tree | 5611b26e3c0abd1355fe3f70bb7d651a687d9ef4 /Lib/doctest.py | |
parent | f33683fd40f505e850f28a5b62d9b4208f7bb0c7 (diff) | |
download | cpython-5b799c1f3d1e96e2d45737bed95a149d356ad5de.zip cpython-5b799c1f3d1e96e2d45737bed95a149d356ad5de.tar.gz cpython-5b799c1f3d1e96e2d45737bed95a149d356ad5de.tar.bz2 |
_do_a_fancy_diff(): Pay no attention to the ellipses behind the curtain.
While a fancy diff can be confusing in the presence of ellipses, so far
I'm finding (2-0-0) that it's much more a major aid in narrowing down the
possibilities when an ellipsis-slinging test fails. So we no longer
refuse to do a fancy diff just because of ellipses.
This isn't ideal; it's just better.
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r-- | Lib/doctest.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py index c01dd64..67de4c5 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -1596,14 +1596,20 @@ class OutputChecker: REPORT_CDIFF | REPORT_NDIFF): return False + # If expected output uses ellipsis, a meaningful fancy diff is - # too hard. - if optionflags & ELLIPSIS and ELLIPSIS_MARKER in want: - return False + # too hard ... or maybe not. In two real-life failures Tim saw, + # a diff was a major help anyway, so this is commented out. + # [todo] _ellipsis_match() knows which pieces do and don't match, + # and could be the basis for a kick-ass diff in this case. + ##if optionflags & ELLIPSIS and ELLIPSIS_MARKER in want: + ## return False + # ndiff does intraline difference marking, so can be useful even - # for 1-line inputs. + # for 1-line differences. 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 @@ -1620,9 +1626,7 @@ class OutputChecker: if not (optionflags & DONT_ACCEPT_BLANKLINE): got = re.sub('(?m)^[ ]*(?=\n)', BLANKLINE_MARKER, got) - # Check if we should use diff. Don't use diff if the actual - # or expected outputs are too short, or if the expected output - # contains an ellipsis marker. + # Check if we should use diff. if self._do_a_fancy_diff(want, got, optionflags): # Split want & got into lines. want_lines = [l+'\n' for l in want.split('\n')] |