MCPcopy Index your code
hub / github.com/python/cpython / test_newlines_output

Method test_newlines_output

Lib/test/test_io/test_textio.py:461–477  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

459 self.assertEqual(txt.read(), "".join(expected))
460
461 def test_newlines_output(self):
462 testdict = {
463 "": b"AAA\nBBB\nCCC\nX\rY\r\nZ",
464 "\n": b"AAA\nBBB\nCCC\nX\rY\r\nZ",
465 "\r": b"AAA\rBBB\rCCC\rX\rY\r\rZ",
466 "\r\n": b"AAA\r\nBBB\r\nCCC\r\nX\rY\r\r\nZ",
467 }
468 tests = [(None, testdict[os.linesep])] + sorted(testdict.items())
469 for newline, expected in tests:
470 buf = self.BytesIO()
471 txt = self.TextIOWrapper(buf, encoding="ascii", newline=newline)
472 txt.write("AAA\nB")
473 txt.write("BB\nCCC\n")
474 txt.write("X\rY\r\nZ")
475 txt.flush()
476 self.assertEqual(buf.closed, False)
477 self.assertEqual(buf.getvalue(), expected)
478
479 def test_destructor(self):
480 l = []

Callers

nothing calls this directly

Calls 5

writeMethod · 0.95
flushMethod · 0.95
getvalueMethod · 0.95
itemsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected