summaryrefslogtreecommitdiffhomepage
path: root/tests/test_sftp.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-09-18 18:00:59 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2014-09-18 18:00:59 -0700
commit848a7209e29d580594d35f299b01db97714caf92 (patch)
tree57425aa20493dccc62bc95e59268fde66eeb368f /tests/test_sftp.py
parent6ee3f1a074d2b13cca2a5d267f16159f294b98c6 (diff)
parent16a8df33eb4e9723fea244959db2b157be825781 (diff)
Merge branch 'master' into switch-to-cryptography
Conflicts: paramiko/ecdsakey.py tests/test_client.py
Diffstat (limited to 'tests/test_sftp.py')
-rwxr-xr-xtests/test_sftp.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/test_sftp.py b/tests/test_sftp.py
index 1ae9781d..72c7ba03 100755
--- a/tests/test_sftp.py
+++ b/tests/test_sftp.py
@@ -23,12 +23,13 @@ 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 binascii import hexlify
import os
+import socket
import sys
-import warnings
import threading
import unittest
+import warnings
+from binascii import hexlify
from tempfile import mkstemp
import paramiko
@@ -195,6 +196,21 @@ class SFTPTest (unittest.TestCase):
pass
sftp = paramiko.SFTP.from_transport(tc)
+ def test_2_sftp_can_be_used_as_context_manager(self):
+ """
+ verify that the sftp session is closed when exiting the context manager
+ """
+ global sftp
+ with sftp:
+ pass
+ try:
+ sftp.open(FOLDER + '/test2', 'w')
+ self.fail('expected exception')
+ except (EOFError, socket.error):
+ pass
+ finally:
+ sftp = paramiko.SFTP.from_transport(tc)
+
def test_3_write(self):
"""
verify that a file can be created and written, and the size is correct.