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

Method testTruncate

Lib/test/test_fileio.py:653–663  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

651 self.fail("no error for invalid mode: %s" % bad_mode)
652
653 def testTruncate(self):
654 f = self.FileIO(TESTFN, 'w')
655 f.write(bytes(bytearray(range(10))))
656 self.assertEqual(f.tell(), 10)
657 f.truncate(5)
658 self.assertEqual(f.tell(), 10)
659 self.assertEqual(f.seek(0, io.SEEK_END), 5)
660 f.truncate(15)
661 self.assertEqual(f.tell(), 5)
662 self.assertEqual(f.seek(0, io.SEEK_END), 15)
663 f.close()
664
665 def testTruncateOnWindows(self):
666 def bug801631():

Callers

nothing calls this directly

Calls 6

writeMethod · 0.95
tellMethod · 0.95
truncateMethod · 0.95
seekMethod · 0.95
closeMethod · 0.95
assertEqualMethod · 0.45

Tested by

no test coverage detected