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

Method testTruncate

Lib/test/test_io/test_fileio.py:652–662  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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