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

Method test_newlines_output

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

Source from the content-addressed store, hash-verified

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 = []

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected