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

Method bug801631

Lib/test/test_io/test_fileio.py:665–686  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

663
664 def testTruncateOnWindows(self):
665 def bug801631():
666 # SF bug <https://bugs.python.org/issue801631>
667 # "file.truncate fault on windows"
668 f = self.FileIO(TESTFN, 'w')
669 f.write(bytes(range(11)))
670 f.close()
671
672 f = self.FileIO(TESTFN,'r+')
673 data = f.read(5)
674 if data != bytes(range(5)):
675 self.fail("Read on file opened for update failed %r" % data)
676 if f.tell() != 5:
677 self.fail("File pos after read wrong %d" % f.tell())
678
679 f.truncate()
680 if f.tell() != 5:
681 self.fail("File pos after ftruncate wrong %d" % f.tell())
682
683 f.close()
684 size = os.path.getsize(TESTFN)
685 if size != 5:
686 self.fail("File size after ftruncate wrong %d" % size)
687
688 try:
689 bug801631()

Callers

nothing calls this directly

Calls 6

writeMethod · 0.95
closeMethod · 0.95
readMethod · 0.95
tellMethod · 0.95
truncateMethod · 0.95
failMethod · 0.45

Tested by

no test coverage detected