summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2013-04-05 11:51:47 -0700
committerJeff Forcier <jeff@bitprophet.org>2013-04-05 11:51:47 -0700
commit73a0d03bdc86a89ca1b452210887f9e86439a8cc (patch)
treed20e0aac157d92bed72c4b7b2e5c30f6e0f32c49
parent9695747875ab26d4acb7feea27e1ece689ad2572 (diff)
parent17ba0d5b61fe0c87b6b7b657d1b74176931f890f (diff)
downloadparamiko-73a0d03bdc86a89ca1b452210887f9e86439a8cc.tar.gz
Merge branch '1.10'
Conflicts: NEWS
-rw-r--r--NEWS6
-rw-r--r--paramiko/sftp_client.py2
-rwxr-xr-xtests/test_sftp.py32
3 files changed, 27 insertions, 13 deletions
diff --git a/NEWS b/NEWS
index 4c54c990..05d31b34 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,12 @@ v1.11.0 (DD MM YYYY)
implementations of all functionality. Thanks to Jason R. Coombs for the
patch.
+v1.10.1 (DD MM YYYY)
+--------------------
+
+* #142: (Fabric #811) SFTP put of empty file will still return the attributes
+ of the put file. Thanks to Jason R. Coombs for the patch.
+
v1.10.0 (1st Mar 2013)
--------------------
diff --git a/paramiko/sftp_client.py b/paramiko/sftp_client.py
index 7df643f5..17ea493c 100644
--- a/paramiko/sftp_client.py
+++ b/paramiko/sftp_client.py
@@ -575,7 +575,7 @@ class SFTPClient (BaseSFTP):
break
finally:
fr.close()
- if confirm and file_size:
+ if confirm:
s = self.stat(remotepath)
if s.st_size != size:
raise IOError('size mismatch in put! %d != %d' % (s.st_size, size))
diff --git a/tests/test_sftp.py b/tests/test_sftp.py
index f95da69c..b1697ea6 100755
--- a/tests/test_sftp.py
+++ b/tests/test_sftp.py
@@ -26,14 +26,12 @@ 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
-import random
-import struct
+import warnings
import sys
import threading
-import time
import unittest
+import StringIO
import paramiko
from stub_sftp import StubServer, StubSFTPServer
@@ -227,7 +225,7 @@ class SFTPTest (unittest.TestCase):
"""
f = sftp.open(FOLDER + '/first.txt', 'w')
try:
- f.write('content!\n');
+ f.write('content!\n')
f.close()
sftp.rename(FOLDER + '/first.txt', FOLDER + '/second.txt')
try:
@@ -438,7 +436,7 @@ class SFTPTest (unittest.TestCase):
self.assertEqual(sftp.readlink(FOLDER + '/link.txt'), 'original.txt')
f = sftp.open(FOLDER + '/link.txt', 'r')
- self.assertEqual(f.readlines(), [ 'original\n' ])
+ self.assertEqual(f.readlines(), ['original\n'])
f.close()
cwd = sftp.normalize('.')
@@ -566,7 +564,6 @@ class SFTPTest (unittest.TestCase):
"""
verify that get/put work.
"""
- import os, warnings
warnings.filterwarnings('ignore', 'tempnam.*')
localname = os.tempnam()
@@ -631,7 +628,7 @@ class SFTPTest (unittest.TestCase):
try:
f = sftp.open(FOLDER + '/unusual.txt', 'wx')
self.fail('expected exception')
- except IOError, x:
+ except IOError:
pass
finally:
sftp.unlink(FOLDER + '/unusual.txt')
@@ -671,12 +668,12 @@ class SFTPTest (unittest.TestCase):
f.close()
try:
f = sftp.open(FOLDER + '/zero', 'r')
- data = f.readv([(0, 12)])
+ f.readv([(0, 12)])
f.close()
f = sftp.open(FOLDER + '/zero', 'r')
f.prefetch()
- data = f.read(100)
+ f.read(100)
f.close()
finally:
sftp.unlink(FOLDER + '/zero')
@@ -685,7 +682,6 @@ class SFTPTest (unittest.TestCase):
"""
verify that get/put work without confirmation.
"""
- import os, warnings
warnings.filterwarnings('ignore', 'tempnam.*')
localname = os.tempnam()
@@ -697,7 +693,7 @@ class SFTPTest (unittest.TestCase):
def progress_callback(x, y):
saved_progress.append((x, y))
res = sftp.put(localname, FOLDER + '/bunny.txt', progress_callback, False)
-
+
self.assertEquals(SFTPAttributes().attr, res.attr)
f = sftp.open(FOLDER + '/bunny.txt', 'r')
@@ -730,3 +726,15 @@ class SFTPTest (unittest.TestCase):
finally:
sftp.remove(FOLDER + '/append.txt')
+ def test_putfo_empty_file(self):
+ """
+ Send an empty file and confirm it is sent.
+ """
+ target = FOLDER + '/empty file.txt'
+ stream = StringIO.StringIO()
+ try:
+ attrs = sftp.putfo(stream, target)
+ # the returned attributes should not be null
+ self.assertNotEqual(attrs, None)
+ finally:
+ sftp.remove(target)