mirror of
https://github.com/python/cpython.git
synced 2025-12-19 07:03:48 +00:00
_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.
This commit is contained in:
parent
f33683fd40
commit
5b799c1f3d
1 changed files with 11 additions and 7 deletions
|
|
@ -1596,14 +1596,20 @@ class OutputChecker:
|
||||||
REPORT_CDIFF |
|
REPORT_CDIFF |
|
||||||
REPORT_NDIFF):
|
REPORT_NDIFF):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# If expected output uses ellipsis, a meaningful fancy diff is
|
# If expected output uses ellipsis, a meaningful fancy diff is
|
||||||
# too hard.
|
# too hard ... or maybe not. In two real-life failures Tim saw,
|
||||||
if optionflags & ELLIPSIS and ELLIPSIS_MARKER in want:
|
# a diff was a major help anyway, so this is commented out.
|
||||||
return False
|
# [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
|
# ndiff does intraline difference marking, so can be useful even
|
||||||
# for 1-line inputs.
|
# for 1-line differences.
|
||||||
if optionflags & REPORT_NDIFF:
|
if optionflags & REPORT_NDIFF:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# The other diff types need at least a few lines to be helpful.
|
# The other diff types need at least a few lines to be helpful.
|
||||||
return want.count('\n') > 2 and got.count('\n') > 2
|
return want.count('\n') > 2 and got.count('\n') > 2
|
||||||
|
|
||||||
|
|
@ -1620,9 +1626,7 @@ class OutputChecker:
|
||||||
if not (optionflags & DONT_ACCEPT_BLANKLINE):
|
if not (optionflags & DONT_ACCEPT_BLANKLINE):
|
||||||
got = re.sub('(?m)^[ ]*(?=\n)', BLANKLINE_MARKER, got)
|
got = re.sub('(?m)^[ ]*(?=\n)', BLANKLINE_MARKER, got)
|
||||||
|
|
||||||
# Check if we should use diff. Don't use diff if the actual
|
# Check if we should use diff.
|
||||||
# or expected outputs are too short, or if the expected output
|
|
||||||
# contains an ellipsis marker.
|
|
||||||
if self._do_a_fancy_diff(want, got, optionflags):
|
if self._do_a_fancy_diff(want, got, optionflags):
|
||||||
# Split want & got into lines.
|
# Split want & got into lines.
|
||||||
want_lines = [l+'\n' for l in want.split('\n')]
|
want_lines = [l+'\n' for l in want.split('\n')]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue