diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-01-31 22:47:27 +0000 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-01-31 22:47:27 +0000 |
commit | 905a2ffe3e5445925a669ab433521ddb66cf1043 (patch) | |
tree | f3a63e9771498b63eebb2797deaede3577695aaf /Lib/test/test_fileio.py | |
parent | 9b661e6ef636bdd71639befc11e7ce71755f6421 (diff) | |
download | cpython-git-905a2ffe3e5445925a669ab433521ddb66cf1043.tar.gz |
Merged revisions 77890 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77890 | antoine.pitrou | 2010-01-31 23:26:04 +0100 (dim., 31 janv. 2010) | 7 lines
- Issue #6939: Fix file I/O objects in the `io` module to keep the original
file position when calling `truncate()`. It would previously change the
file position to the given argument, which goes against the tradition of
ftruncate() and other truncation APIs. Patch by Pascal Chambon.
........
Diffstat (limited to 'Lib/test/test_fileio.py')
-rw-r--r-- | Lib/test/test_fileio.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py index d35549f224..8348f6ea9e 100644 --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -328,6 +328,17 @@ class OtherFileTests(unittest.TestCase): f.close() self.fail("no error for invalid mode: %s" % bad_mode) + def testTruncate(self): + f = _FileIO(TESTFN, 'w') + f.write(bytes(bytearray(range(10)))) + self.assertEqual(f.tell(), 10) + f.truncate(5) + self.assertEqual(f.tell(), 10) + self.assertEqual(f.seek(0, os.SEEK_END), 5) + f.truncate(15) + self.assertEqual(f.tell(), 5) + self.assertEqual(f.seek(0, os.SEEK_END), 15) + def testTruncateOnWindows(self): def bug801631(): # SF bug <http://www.python.org/sf/801631> |