Skip to content

Commit

Permalink
Merge branch '1.10'
Browse files Browse the repository at this point in the history
Conflicts:
	NEWS
  • Loading branch information
bitprophet committed Apr 5, 2013
2 parents 9695747 + 17ba0d5 commit 73a0d03
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
6 changes: 6 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)
--------------------

Expand Down
2 changes: 1 addition & 1 deletion paramiko/sftp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def putfo(self, fl, remotepath, file_size=0, callback=None, confirm=True):
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))
Expand Down
32 changes: 20 additions & 12 deletions tests/test_sftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@
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
Expand Down Expand Up @@ -227,7 +225,7 @@ def test_5_rename(self):
"""
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:
Expand Down Expand Up @@ -438,7 +436,7 @@ def test_C_symlink(self):
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('.')
Expand Down Expand Up @@ -566,7 +564,6 @@ def test_H_get_put(self):
"""
verify that get/put work.
"""
import os, warnings
warnings.filterwarnings('ignore', 'tempnam.*')

localname = os.tempnam()
Expand Down Expand Up @@ -631,7 +628,7 @@ def test_J_x_flag(self):
try:
f = sftp.open(FOLDER + '/unusual.txt', 'wx')
self.fail('expected exception')
except IOError, x:
except IOError:
pass
finally:
sftp.unlink(FOLDER + '/unusual.txt')
Expand Down Expand Up @@ -671,12 +668,12 @@ def test_M_bad_readv(self):
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')
Expand All @@ -685,7 +682,6 @@ def test_N_put_without_confirm(self):
"""
verify that get/put work without confirmation.
"""
import os, warnings
warnings.filterwarnings('ignore', 'tempnam.*')

localname = os.tempnam()
Expand All @@ -697,7 +693,7 @@ def test_N_put_without_confirm(self):
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')
Expand Down Expand Up @@ -730,3 +726,15 @@ def XXX_test_M_seek_append(self):
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)

0 comments on commit 73a0d03

Please sign in to comment.