summaryrefslogtreecommitdiffhomepage
path: root/tests/test_sftp.py
diff options
context:
space:
mode:
authorAntoine Brenner <antoine@gymglish.com>2014-04-16 21:58:03 +0200
committerJeff Forcier <jeff@bitprophet.org>2014-04-17 17:52:34 -0400
commit3fce8abf68f386d18f2fad9f086e0d436af57b3a (patch)
tree429d9edcb8fdeb662607a99bd812c02cc7a68b3b /tests/test_sftp.py
parent9b2388cad56b803ef71d1f3c7523361ecdd16425 (diff)
BufferedFile.read() now returns byte strings instead of text strings
It is the right thing to do since we have no idea what encoding the file is in, or even if the file is text data. BufferedFile.readline() is unchanged and returns text strings assuming the file is utf-8 encoded. This should fix the following issue: http://comments.gmane.org/gmane.comp.sysutils.backup.obnam/252 Antoine Brenner Conflicts: sites/www/changelog.rst
Diffstat (limited to 'tests/test_sftp.py')
-rwxr-xr-xtests/test_sftp.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/test_sftp.py b/tests/test_sftp.py
index e0534eb0..720b8215 100755
--- a/tests/test_sftp.py
+++ b/tests/test_sftp.py
@@ -405,7 +405,7 @@ class SFTPTest (unittest.TestCase):
self.assertEqual(sftp.stat(FOLDER + '/testing.txt').st_size, 13)
with sftp.open(FOLDER + '/testing.txt', 'r') as f:
data = f.read(20)
- self.assertEqual(data, 'hello kiddy.\n')
+ self.assertEqual(data, b'hello kiddy.\n')
finally:
sftp.remove(FOLDER + '/testing.txt')
@@ -466,8 +466,8 @@ class SFTPTest (unittest.TestCase):
f.write('?\n')
with sftp.open(FOLDER + '/happy.txt', 'r') as f:
- self.assertEqual(f.readline(), 'full line?\n')
- self.assertEqual(f.read(7), 'partial')
+ self.assertEqual(f.readline(), u'full line?\n')
+ self.assertEqual(f.read(7), b'partial')
finally:
try:
sftp.remove(FOLDER + '/happy.txt')
@@ -662,8 +662,8 @@ class SFTPTest (unittest.TestCase):
fd, localname = mkstemp()
os.close(fd)
- text = 'All I wanted was a plastic bunny rabbit.\n'
- with open(localname, 'w') as f:
+ text = b'All I wanted was a plastic bunny rabbit.\n'
+ with open(localname, 'wb') as f:
f.write(text)
saved_progress = []