diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-01-27 21:48:46 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-01-27 21:48:46 (GMT) |
commit | ca5a06aaa968ae767329f8afedbaf17fc337416f (patch) | |
tree | 1c0f8bfdd0469ce707d41b99371855f6f3f8ae91 /Lib/test/test_memoryio.py | |
parent | f3330144679453a66b9baf54963462d8cbd095f8 (diff) | |
download | cpython-ca5a06aaa968ae767329f8afedbaf17fc337416f.zip cpython-ca5a06aaa968ae767329f8afedbaf17fc337416f.tar.gz cpython-ca5a06aaa968ae767329f8afedbaf17fc337416f.tar.bz2 |
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_memoryio.py')
-rw-r--r-- | Lib/test/test_memoryio.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py index d538a7e..85b5e13 100644 --- a/Lib/test/test_memoryio.py +++ b/Lib/test/test_memoryio.py @@ -32,7 +32,7 @@ class MemoryTestMixin: self.assertEqual(f.seek(0), 0) self.assertEqual(f.write(t("h")), 1) self.assertEqual(f.truncate(12), 12) - self.assertEqual(f.tell(), 12) + self.assertEqual(f.tell(), 1) def test_write(self): buf = self.buftype("hello world\n") @@ -83,7 +83,8 @@ class MemoryTestMixin: # truncate() accepts long objects self.assertEqual(memio.truncate(4L), 4) self.assertEqual(memio.getvalue(), buf[:4]) - self.assertEqual(memio.tell(), 4) + self.assertEqual(memio.tell(), 6) + memio.seek(0, 2) memio.write(buf) self.assertEqual(memio.getvalue(), buf[:4] + buf) pos = memio.tell() |