From 93f3cae64ffa5698175b6f89a677b64a66a29a59 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Wed, 13 Jul 2005 08:35:15 +0000 Subject: [project @ Arch-1:robey@lag.net--2005-master-shake%paramiko--dev--1--patch-33] add SFTPClient.put and SFTPClient.get, and make sftp file objects auto-close on del --- tests/test_sftp.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests') diff --git a/tests/test_sftp.py b/tests/test_sftp.py index f4b5fea2..992c9dc3 100755 --- a/tests/test_sftp.py +++ b/tests/test_sftp.py @@ -540,3 +540,32 @@ class SFTPTest (unittest.TestCase): except: pass + def test_J_get_put(self): + """ + verify that get/put work. + """ + import os, warnings + warnings.filterwarnings('ignore', 'tempnam.*') + + localname = os.tempnam() + text = 'All I wanted was a plastic bunny rabbit.\n' + f = open(localname, 'w') + f.write(text) + f.close() + sftp.put(localname, FOLDER + '/bunny.txt') + + f = sftp.open(FOLDER + '/bunny.txt', 'r') + self.assertEquals(text, f.read(128)) + f.close() + + os.unlink(localname) + localname = os.tempnam() + sftp.get(FOLDER + '/bunny.txt', localname) + + f = open(localname, 'r') + self.assertEquals(text, f.read(128)) + f.close() + + os.unlink(localname) + sftp.unlink(FOLDER + '/bunny.txt') + -- cgit v1.2.3