diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-01-21 00:45:36 +0000 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-01-21 00:45:36 +0000 |
commit | e741cc607c226c76fef473bf772d42fc63269b9b (patch) | |
tree | c7914f5e141059584cfc3ebea80b01009bb0ad3d /Lib/test/test_io.py | |
parent | acdc84abcf106e4178d18363b899d0f4218008f4 (diff) | |
download | cpython-git-e741cc607c226c76fef473bf772d42fc63269b9b.tar.gz |
Issue #5008: When a file is opened in append mode with the new IO library,
do an explicit seek to the end of file (so that e.g. tell() returns the
file size rather than 0). This is consistent with the behaviour of the
traditional 2.x file object.
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r-- | Lib/test/test_io.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 967018ea45..f0b38b6f7a 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -232,6 +232,17 @@ class IOTest(unittest.TestCase): else: self.fail("1/0 didn't raise an exception") + # issue 5008 + def test_append_mode_tell(self): + with io.open(test_support.TESTFN, "wb") as f: + f.write(b"xxx") + with io.open(test_support.TESTFN, "ab", buffering=0) as f: + self.assertEqual(f.tell(), 3) + with io.open(test_support.TESTFN, "ab") as f: + self.assertEqual(f.tell(), 3) + with io.open(test_support.TESTFN, "a") as f: + self.assert_(f.tell() > 0) + def test_destructor(self): record = [] class MyFileIO(io.FileIO): |