summaryrefslogtreecommitdiffstats
path: root/Lib/doctest.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-02-14 06:35:35 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-02-14 06:35:35 (GMT)
commitf9bb4969af0b9cedeb837ac5260b03c011df9a7c (patch)
tree3544732a8a7f362fe6b66be0f2a4d0d4d96ff7eb /Lib/doctest.py
parent7530208d8b1a20a0c1a94eeec451beae6a6ba80c (diff)
downloadcpython-f9bb4969af0b9cedeb837ac5260b03c011df9a7c.zip
cpython-f9bb4969af0b9cedeb837ac5260b03c011df9a7c.tar.gz
cpython-f9bb4969af0b9cedeb837ac5260b03c011df9a7c.tar.bz2
Miranda newlines: if anything at all was written to stdout, supply a
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.
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r--Lib/doctest.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py
index b3ef98b..9c0ecc8 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -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):