| 3119 | self.assertEqual(txt.read(), "".join(expected)) |
| 3120 | |
| 3121 | def test_newlines_output(self): |
| 3122 | testdict = { |
| 3123 | "": b"AAA\nBBB\nCCC\nX\rY\r\nZ", |
| 3124 | "\n": b"AAA\nBBB\nCCC\nX\rY\r\nZ", |
| 3125 | "\r": b"AAA\rBBB\rCCC\rX\rY\r\rZ", |
| 3126 | "\r\n": b"AAA\r\nBBB\r\nCCC\r\nX\rY\r\r\nZ", |
| 3127 | } |
| 3128 | tests = [(None, testdict[os.linesep])] + sorted(testdict.items()) |
| 3129 | for newline, expected in tests: |
| 3130 | buf = self.BytesIO() |
| 3131 | txt = self.TextIOWrapper(buf, encoding="ascii", newline=newline) |
| 3132 | txt.write("AAA\nB") |
| 3133 | txt.write("BB\nCCC\n") |
| 3134 | txt.write("X\rY\r\nZ") |
| 3135 | txt.flush() |
| 3136 | self.assertEqual(buf.closed, False) |
| 3137 | self.assertEqual(buf.getvalue(), expected) |
| 3138 | |
| 3139 | def test_destructor(self): |
| 3140 | l = [] |