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

Method test_readline

Lib/test/test_io/test_general.py:308–320  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

306 self.read_ops(f, True)
307
308 def test_readline(self):
309 with self.open(os_helper.TESTFN, "wb") as f:
310 f.write(b"abc\ndef\nxyzzy\nfoo\x00bar\nanother line")
311 with self.open(os_helper.TESTFN, "rb") as f:
312 self.assertEqual(f.readline(), b"abc\n")
313 self.assertEqual(f.readline(10), b"def\n")
314 self.assertEqual(f.readline(2), b"xy")
315 self.assertEqual(f.readline(4), b"zzy\n")
316 self.assertEqual(f.readline(), b"foo\x00bar\n")
317 self.assertEqual(f.readline(None), b"another line")
318 self.assertRaises(TypeError, f.readline, 5.3)
319 with self.open(os_helper.TESTFN, "r", encoding="utf-8") as f:
320 self.assertRaises(TypeError, f.readline, 5.3)
321
322 def test_readline_nonsizeable(self):
323 # Issue #30061

Callers

nothing calls this directly

Calls 5

openMethod · 0.45
writeMethod · 0.45
assertEqualMethod · 0.45
readlineMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected