diff options
author | Walter Dörwald <walter@livinglogic.de> | 2007-06-06 16:31:14 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2007-06-06 16:31:14 (GMT) |
commit | 3a77c7ab16d737a19cfb3fae4bd0f92517abe149 (patch) | |
tree | a106a1d6a89baf1d9077e49ca78081123fc42b93 /Lib/test/test_fileio.py | |
parent | fee1af9d1cf1836113e61e41acd8e913736644a1 (diff) | |
download | cpython-3a77c7ab16d737a19cfb3fae4bd0f92517abe149.zip cpython-3a77c7ab16d737a19cfb3fae4bd0f92517abe149.tar.gz cpython-3a77c7ab16d737a19cfb3fae4bd0f92517abe149.tar.bz2 |
If append mode is specified seek to the end of the file.
Add a test to test_fileio.py for this.
Diffstat (limited to 'Lib/test/test_fileio.py')
-rw-r--r-- | Lib/test/test_fileio.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py index 064ec0c..8cf79df 100644 --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -205,6 +205,24 @@ class OtherFileTests(unittest.TestCase): finally: os.unlink(TESTFN) + def testAppend(self): + try: + f = open(TESTFN, 'wb') + f.write(b'spam') + f.close() + f = open(TESTFN, 'ab') + f.write(b'eggs') + f.close() + f = open(TESTFN, 'rb') + d = f.read() + f.close() + self.assertEqual(d, b'spameggs') + finally: + try: + os.unlink(TESTFN) + except: + pass + def test_main(): # Historically, these tests have been sloppy about removing TESTFN. # So get rid of it no matter what. |