_ellipsis_match(): Removed special-casing of "...\n". The semantics
are non-obvious either way because the newline character "is invisible", but it's still there all the same, and it's easier to explain/predict if that reality is left alone.
This commit is contained in:
parent
5268c3955a
commit
e594bee535
@ -398,10 +398,6 @@ def _ellipsis_match(want, got):
|
|||||||
"""
|
"""
|
||||||
if ELLIPSIS_MARKER not in want:
|
if ELLIPSIS_MARKER not in want:
|
||||||
return want == got
|
return want == got
|
||||||
# Remove \n from ...\n, else the newline will be required,
|
|
||||||
# and (for example) ... on a line by itself can't match
|
|
||||||
# nothing gracefully.
|
|
||||||
want = want.replace(ELLIPSIS_MARKER + '\n', ELLIPSIS_MARKER)
|
|
||||||
|
|
||||||
# Find "the real" strings.
|
# Find "the real" strings.
|
||||||
ws = want.split(ELLIPSIS_MARKER)
|
ws = want.split(ELLIPSIS_MARKER)
|
||||||
|
@ -785,40 +785,17 @@ output to match any substring in the actual output:
|
|||||||
>>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
|
>>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
|
||||||
(0, 1)
|
(0, 1)
|
||||||
|
|
||||||
... should also match nothing gracefully (note that a regular-expression
|
... also matches nothing:
|
||||||
implementation of ELLIPSIS would take a loooong time to match this one!):
|
|
||||||
|
|
||||||
>>> for i in range(100):
|
>>> for i in range(100):
|
||||||
... print i**2 #doctest: +ELLIPSIS
|
... print i**2, #doctest: +ELLIPSIS
|
||||||
0
|
0 1...4...9 16 ... 36 49 64 ... 9801
|
||||||
...
|
|
||||||
1
|
|
||||||
...
|
|
||||||
......
|
|
||||||
...
|
|
||||||
36
|
|
||||||
...
|
|
||||||
...
|
|
||||||
...
|
|
||||||
49
|
|
||||||
64
|
|
||||||
.........
|
|
||||||
9801
|
|
||||||
...
|
|
||||||
|
|
||||||
... can be surprising; e.g., this test passes:
|
... can be surprising; e.g., this test passes:
|
||||||
|
|
||||||
>>> for i in range(21): #doctest: +ELLIPSIS
|
>>> for i in range(21): #doctest: +ELLIPSIS
|
||||||
... print i
|
... print i,
|
||||||
0
|
0 1 2 ...1...2...0
|
||||||
1
|
|
||||||
2
|
|
||||||
...
|
|
||||||
1
|
|
||||||
...
|
|
||||||
2
|
|
||||||
...
|
|
||||||
0
|
|
||||||
|
|
||||||
Examples from the docs:
|
Examples from the docs:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user