diff options
author | Robey Pointer <robey@lag.net> | 2006-08-22 19:55:38 -0700 |
---|---|---|
committer | Robey Pointer <robey@lag.net> | 2006-08-22 19:55:38 -0700 |
commit | 145ceab54c454f6872e34c426d6f9c0aadccbd85 (patch) | |
tree | df0af809a90f46ca7a241ee2bfde4071395810bb /tests/test_sftp.py | |
parent | 738e81033a2f0170990176c7d77c9d7e79abfd1a (diff) |
[project @ robey@lag.net-20060823025538-3f8a4d761d7d4118]
when a file is open for append, don't stat to get the file position unless the user asks for it explicitly
Diffstat (limited to 'tests/test_sftp.py')
-rwxr-xr-x | tests/test_sftp.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_sftp.py b/tests/test_sftp.py index 1e2785d1..db210131 100755 --- a/tests/test_sftp.py +++ b/tests/test_sftp.py @@ -648,3 +648,24 @@ class SFTPTest (unittest.TestCase): f.close() finally: sftp.unlink(FOLDER + '/zero') + + def test_M_seek_append(self): + """ + verify that seek does't affect writes during append. + """ + f = sftp.open(FOLDER + '/append.txt', 'a') + try: + f.write('first line\nsecond line\n') + f.seek(11, f.SEEK_SET) + f.write('third line\n') + f.close() + + f = sftp.open(FOLDER + '/append.txt', 'r') + self.assertEqual(f.stat().st_size, 34) + self.assertEqual(f.readline(), 'first line\n') + self.assertEqual(f.readline(), 'second line\n') + self.assertEqual(f.readline(), 'third line\n') + f.close() + finally: + sftp.remove(FOLDER + '/append.txt') + |