Fix an unfinished though in my own test code.

(testNewlinesInput and testNewlinesOutput are mine, not Tony's.)
This commit is contained in:
Guido van Rossum 2007-08-18 22:05:58 +00:00
parent 8358db22fa
commit 1836358c01

View file

@ -571,12 +571,12 @@ class TextIOWrapperTest(unittest.TestCase):
self.assertEquals(txt.read(), "".join(expected)) self.assertEquals(txt.read(), "".join(expected))
def testNewlinesOutput(self): def testNewlinesOutput(self):
import os
orig_linesep = os.linesep
data = "AAA\nBBB\rCCC\n" data = "AAA\nBBB\rCCC\n"
data_lf = b"AAA\nBBB\rCCC\n" data_lf = b"AAA\nBBB\rCCC\n"
data_cr = b"AAA\rBBB\rCCC\r" data_cr = b"AAA\rBBB\rCCC\r"
data_crlf = b"AAA\r\nBBB\rCCC\r\n" data_crlf = b"AAA\r\nBBB\rCCC\r\n"
save_linesep = os.linesep
try:
for os.linesep, newline, expected in [ for os.linesep, newline, expected in [
("\n", None, data_lf), ("\n", None, data_lf),
("\r\n", None, data_crlf), ("\r\n", None, data_crlf),
@ -594,6 +594,8 @@ class TextIOWrapperTest(unittest.TestCase):
txt.write(data) txt.write(data)
txt.close() txt.close()
self.assertEquals(buf.getvalue(), expected) self.assertEquals(buf.getvalue(), expected)
finally:
os.linesep = save_linesep
# Systematic tests of the text I/O API # Systematic tests of the text I/O API