summaryrefslogtreecommitdiffhomepage
path: root/tests/test_sftp.py
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2013-03-19 13:36:52 -0700
committerJeff Forcier <jeff@bitprophet.org>2013-03-19 13:36:52 -0700
commita7ee2509e48d7e2bb533ce5e50796b9a887c7a8a (patch)
tree69ac6ffb7193e8b64bd97fd03db70c6a21485480 /tests/test_sftp.py
parent5f5137414c91c931f04522b1bb8c2800294d6a90 (diff)
parentd5db60329701df2423909773af9cc9aa5df4d4f6 (diff)
Merge branch 'master' into 112-int
Conflicts: paramiko/win_pageant.py
Diffstat (limited to 'tests/test_sftp.py')
-rwxr-xr-xtests/test_sftp.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_sftp.py b/tests/test_sftp.py
index 2eadabcd..f95da69c 100755
--- a/tests/test_sftp.py
+++ b/tests/test_sftp.py
@@ -23,6 +23,8 @@ a real actual sftp server is contacted, and a new folder is created there to
do test file operations in (so no existing files will be harmed).
"""
+from __future__ import with_statement
+
from binascii import hexlify
import logging
import os
@@ -188,6 +190,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.