MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_newlines_input

Method test_newlines_input

Lib/test/test_io.py:3105–3119  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3103 self.assertEqual(len(got_lines), len(exp_lines))
3104
3105 def test_newlines_input(self):
3106 testdata = b"AAA\nBB\x00B\nCCC\rDDD\rEEE\r\nFFF\r\nGGG"
3107 normalized = testdata.replace(b"\r\n", b"\n").replace(b"\r", b"\n")
3108 for newline, expected in [
3109 (None, normalized.decode("ascii").splitlines(keepends=True)),
3110 ("", testdata.decode("ascii").splitlines(keepends=True)),
3111 ("\n", ["AAA\n", "BB\x00B\n", "CCC\rDDD\rEEE\r\n", "FFF\r\n", "GGG"]),
3112 ("\r\n", ["AAA\nBB\x00B\nCCC\rDDD\rEEE\r\n", "FFF\r\n", "GGG"]),
3113 ("\r", ["AAA\nBB\x00B\nCCC\r", "DDD\r", "EEE\r", "\nFFF\r", "\nGGG"]),
3114 ]:
3115 buf = self.BytesIO(testdata)
3116 txt = self.TextIOWrapper(buf, encoding="ascii", newline=newline)
3117 self.assertEqual(txt.readlines(), expected)
3118 txt.seek(0)
3119 self.assertEqual(txt.read(), "".join(expected))
3120
3121 def test_newlines_output(self):
3122 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