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

Method test_newlines_input

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

Source from the content-addressed store, hash-verified

443 self.assertEqual(len(got_lines), len(exp_lines))
444
445 def test_newlines_input(self):
446 testdata = b"AAA\nBB\x00B\nCCC\rDDD\rEEE\r\nFFF\r\nGGG"
447 normalized = testdata.replace(b"\r\n", b"\n").replace(b"\r", b"\n")
448 for newline, expected in [
449 (None, normalized.decode("ascii").splitlines(keepends=True)),
450 ("", testdata.decode("ascii").splitlines(keepends=True)),
451 ("\n", ["AAA\n", "BB\x00B\n", "CCC\rDDD\rEEE\r\n", "FFF\r\n", "GGG"]),
452 ("\r\n", ["AAA\nBB\x00B\nCCC\rDDD\rEEE\r\n", "FFF\r\n", "GGG"]),
453 ("\r", ["AAA\nBB\x00B\nCCC\r", "DDD\r", "EEE\r", "\nFFF\r", "\nGGG"]),
454 ]:
455 buf = self.BytesIO(testdata)
456 txt = self.TextIOWrapper(buf, encoding="ascii", newline=newline)
457 self.assertEqual(txt.readlines(), expected)
458 txt.seek(0)
459 self.assertEqual(txt.read(), "".join(expected))
460
461 def test_newlines_output(self):
462 testdict = {

Callers

nothing calls this directly

Calls 8

seekMethod · 0.95
readMethod · 0.95
replaceMethod · 0.45
splitlinesMethod · 0.45
decodeMethod · 0.45
assertEqualMethod · 0.45
readlinesMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected