From 145ceab54c454f6872e34c426d6f9c0aadccbd85 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Tue, 22 Aug 2006 19:55:38 -0700 Subject: [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 --- tests/test_sftp.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests/test_sftp.py') 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') + -- cgit v1.2.3