]> granicus.if.org Git - python/commitdiff
In output_difference(), replace blank lines in `want` with <BLANKLINE>
authorEdward Loper <edloper@gradient.cis.upenn.edu>
Thu, 12 Aug 2004 02:43:49 +0000 (02:43 +0000)
committerEdward Loper <edloper@gradient.cis.upenn.edu>
Thu, 12 Aug 2004 02:43:49 +0000 (02:43 +0000)
(rather than replacing <BLANKLINE> with blank lines in `got`).  This
makes it easier to see what's intended.

Lib/doctest.py

index 9b912772923851ce4fb279ac13920fe2328842d7..a98df1abffced5f41cb55ff886484a9cfa84d939 100644 (file)
@@ -1492,10 +1492,10 @@ class OutputChecker:
         compare `want` and `got`.  `indent` is the indentation of the
         original example.
         """
-        # If <BLANKLINE>s are being used, then replace <BLANKLINE>
-        # with blank lines in the expected output string.
+        # If <BLANKLINE>s are being used, then replace blank lines
+        # with <BLANKLINE> in the actual output string.
         if not (optionflags & DONT_ACCEPT_BLANKLINE):
-            want = re.sub('(?m)^%s$' % re.escape(BLANKLINE_MARKER), '', want)
+            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