summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_io.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-01-21 00:55:13 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-01-21 00:55:13 (GMT)
commit08838b6acf4d0fecefcf4222632719985190dd67 (patch)
treed11df3aa012f72d2718d5a8ac50ef1a392b98137 /Lib/test/test_io.py
parent6268cbc77190cf6b4112a272f2870d5361903605 (diff)
downloadcpython-08838b6acf4d0fecefcf4222632719985190dd67.zip
cpython-08838b6acf4d0fecefcf4222632719985190dd67.tar.gz
cpython-08838b6acf4d0fecefcf4222632719985190dd67.tar.bz2
Merged revisions 68835 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r68835 | antoine.pitrou | 2009-01-21 01:45:36 +0100 (mer., 21 janv. 2009) | 6 lines 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.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 489e560..6265258 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -233,6 +233,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(support.TESTFN, "wb") as f:
+ f.write(b"xxx")
+ with io.open(support.TESTFN, "ab", buffering=0) as f:
+ self.assertEqual(f.tell(), 3)
+ with io.open(support.TESTFN, "ab") as f:
+ self.assertEqual(f.tell(), 3)
+ with io.open(support.TESTFN, "a") as f:
+ self.assert_(f.tell() > 0)
+
def test_destructor(self):
record = []
class MyFileIO(io.FileIO):