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

Method test_basic_io

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

Source from the content-addressed store, hash-verified

526 # Systematic tests of the text I/O API
527
528 def test_basic_io(self):
529 for chunksize in (1, 2, 3, 4, 5, 15, 16, 17, 31, 32, 33, 63, 64, 65):
530 for enc in "ascii", "latin-1", "utf-8" :# , "utf-16-be", "utf-16-le":
531 f = self.open(os_helper.TESTFN, "w+", encoding=enc)
532 f._CHUNK_SIZE = chunksize
533 self.assertEqual(f.write("abc"), 3)
534 f.close()
535 f = self.open(os_helper.TESTFN, "r+", encoding=enc)
536 f._CHUNK_SIZE = chunksize
537 self.assertEqual(f.tell(), 0)
538 self.assertEqual(f.read(), "abc")
539 cookie = f.tell()
540 self.assertEqual(f.seek(0), 0)
541 self.assertEqual(f.read(None), "abc")
542 f.seek(0)
543 self.assertEqual(f.read(2), "ab")
544 self.assertEqual(f.read(1), "c")
545 self.assertEqual(f.read(1), "")
546 self.assertEqual(f.read(), "")
547 self.assertEqual(f.tell(), cookie)
548 self.assertEqual(f.seek(0), 0)
549 self.assertEqual(f.seek(0, 2), cookie)
550 self.assertEqual(f.write("def"), 3)
551 self.assertEqual(f.seek(cookie), cookie)
552 self.assertEqual(f.read(), "def")
553 if enc.startswith("utf"):
554 self.multi_line_test(f, enc)
555 f.close()
556
557 def multi_line_test(self, f, enc):
558 f.seek(0)

Callers

nothing calls this directly

Calls 9

multi_line_testMethod · 0.95
openMethod · 0.45
assertEqualMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45
tellMethod · 0.45
readMethod · 0.45
seekMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected