]> granicus.if.org Git - python/commitdiff
Miranda newlines: if anything at all was written to stdout, supply a
authorTim Peters <tim.peters@gmail.com>
Wed, 14 Feb 2001 06:35:35 +0000 (06:35 +0000)
committerTim Peters <tim.peters@gmail.com>
Wed, 14 Feb 2001 06:35:35 +0000 (06:35 +0000)
newline at the end if there isn't one already.  Expected output has no
way to indicate that a trailing newline was not expected, and in the
interpreter shell *Python* supplies the trailing newline before printing
the next prompt.

Lib/doctest.py

index b3ef98b879ee5a8ca80c8b128f6915203a519e8c..9c0ecc87a8b511a9dfc545c2cd4a42afb09b4987 100644 (file)
@@ -444,7 +444,13 @@ class _SpoofOut:
     def write(self, s):
         self.buf.append(s)
     def get(self):
-        return "".join(self.buf)
+        guts = "".join(self.buf)
+        # If anything at all was written, make sure there's a trailing
+        # newline.  There's no way for the expected output to indicate
+        # that a trailing newline is missing.
+        if guts and not guts.endswith("\n"):
+            guts = guts + "\n"
+        return guts
     def clear(self):
         self.buf = []
     def flush(self):