]> granicus.if.org Git - python/commitdiff
_ellipsis_match(): Removed special-casing of "...\n". The semantics
authorTim Peters <tim.peters@gmail.com>
Sun, 22 Aug 2004 01:47:51 +0000 (01:47 +0000)
committerTim Peters <tim.peters@gmail.com>
Sun, 22 Aug 2004 01:47:51 +0000 (01:47 +0000)
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.

Lib/doctest.py
Lib/test/test_doctest.py

index 6e6661d1316a089d1c976c10f3ed546cac6f711a..25b14ca8e5712627c8ee9653186ddb1e286a97c4 100644 (file)
@@ -398,10 +398,6 @@ def _ellipsis_match(want, got):
     """
     if ELLIPSIS_MARKER not in want:
         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.
     ws = want.split(ELLIPSIS_MARKER)
index 245a9f420f8dc19334c1e4c01f3479fe7819c3b3..3c5fa084d46260323c2248e930289729ef508c77 100644 (file)
@@ -785,40 +785,17 @@ output to match any substring in the actual output:
     >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
     (0, 1)
 
-    ... should also match nothing gracefully (note that a regular-expression
-    implementation of ELLIPSIS would take a loooong time to match this one!):
+    ... also matches nothing:
 
     >>> for i in range(100):
-    ...     print i**2 #doctest: +ELLIPSIS
-    0
-    ...
-    1
-    ...
-    ......
-    ...
-    36
-    ...
-    ...
-    ...
-    49
-    64
-    .........
-    9801
-    ...
+    ...     print i**2, #doctest: +ELLIPSIS
+    0 1...4...9 16 ... 36 49 64 ... 9801
 
     ... can be surprising; e.g., this test passes:
 
     >>> for i in range(21): #doctest: +ELLIPSIS
-    ...     print i
-    0
-    1
-    2
-    ...
-    1
-    ...
-    2
-    ...
-    0
+    ...     print i,
+    0 1 2 ...1...2...0
 
     Examples from the docs: