summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-01-04 23:39:48 +0000
committerMichael Williamson <mike@zwobble.org>2013-01-04 23:43:15 +0000
commit602250fdf9515a8127cd567d79afa8134d4cf923 (patch)
treefeb42e011f33964bd5ebacdd5c7a3be63830a30c /tests
parent21cb9a2d86b2c0419444ea7c2e5e1c35a62b6373 (diff)
downloadparamiko-602250fdf9515a8127cd567d79afa8134d4cf923.tar.gz
Turn SFTPFile into a context manager
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_sftp.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test_sftp.py b/tests/test_sftp.py
index 2eadabcd..39c8aa83 100755
--- a/tests/test_sftp.py
+++ b/tests/test_sftp.py
@@ -188,6 +188,17 @@ class SFTPTest (unittest.TestCase):
finally:
sftp.remove(FOLDER + '/duck.txt')
+ def test_3_sftp_file_can_be_used_as_context_manager(self):
+ """
+ verify that an opened file can be used as a context manager
+ """
+ try:
+ with sftp.open(FOLDER + '/duck.txt', 'w') as f:
+ f.write(ARTICLE)
+ self.assertEqual(sftp.stat(FOLDER + '/duck.txt').st_size, 1483)
+ finally:
+ sftp.remove(FOLDER + '/duck.txt')
+
def test_4_append(self):
"""
verify that a file can be opened for append, and tell() still works.