diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2014-04-16 15:07:56 -0400 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2014-04-16 15:07:56 -0400 |
commit | 6e9abc39cfff94e0dc36ebe6b939caa8d2eafee0 (patch) | |
tree | dad2738b0367e6786e66fd0a30fe2865b8d4e952 /tests/test_sftp.py | |
parent | dd2e23a23e4223fc8d520595bb973d5605b58e74 (diff) |
Fix logging error in sftp_client for filenames containing the character.
Bug reported here:
http://vlists.pepperfish.net/pipermail/obnam-flarn.net/2013-May/000767.html
Antoine Brenner
Backported to 1.11 by @bitprophet
Conflicts:
paramiko/sftp_client.py
sites/www/changelog.rst
tests/test_sftp.py
Diffstat (limited to 'tests/test_sftp.py')
-rwxr-xr-x | tests/test_sftp.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_sftp.py b/tests/test_sftp.py index cc512c18..a136f823 100755 --- a/tests/test_sftp.py +++ b/tests/test_sftp.py @@ -36,6 +36,7 @@ import StringIO import paramiko from stub_sftp import StubServer, StubSFTPServer from loop import LoopSocket +import paramiko.util from paramiko.sftp_attr import SFTPAttributes ARTICLE = ''' @@ -738,3 +739,25 @@ class SFTPTest (unittest.TestCase): self.assertNotEqual(attrs, None) finally: sftp.remove(target) + + + def test_N_file_with_percent(self): + """ + verify that we can create a file with a '%' in the filename. + ( it needs to be properly escaped by _log() ) + """ + self.assertTrue( paramiko.util.get_logger("paramiko").handlers, "This unit test requires logging to be enabled" ) + f = sftp.open(FOLDER + '/test%file', 'w') + try: + self.assertEqual(f.stat().st_size, 0) + finally: + f.close() + sftp.remove(FOLDER + '/test%file') + + +if __name__ == '__main__': + SFTPTest.init_loopback() + # logging is required by test_N_file_with_percent + paramiko.util.log_to_file('test_sftp.log') + from unittest import main + main() |