diff options
author | achapp <adamdchappell@gmail.com> | 2014-11-24 18:08:26 -0600 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2014-12-17 15:51:19 -0800 |
commit | 34c4d0c4a29c8b3c26925c2a05a9b0e50a83f617 (patch) | |
tree | e966695812f921bd4dc2d5242dc71f49f8449406 | |
parent | b3ed2d5b7eef96a349809517e2d782fca3906e94 (diff) |
Test update/Fix progress temp save
Edited test to catch readline error. file.py code change in progress
(DOES NOT WORK PROPERLY) so saving it temporarily.
-rw-r--r-- | paramiko/file.py | 9 | ||||
-rwxr-xr-x | tests/test_file.py | 4 |
2 files changed, 10 insertions, 3 deletions
diff --git a/paramiko/file.py b/paramiko/file.py index 0a7fbcba..139c453b 100644 --- a/paramiko/file.py +++ b/paramiko/file.py @@ -221,8 +221,8 @@ class BufferedFile (object): # truncate line and return self._rbuffer = line[size:] line = line[:size] - self._pos += len(line) - return line if self._flags & self.FLAG_BINARY else u(line) + #self._pos += len(line) + break#return line if self._flags & self.FLAG_BINARY else u(line) n = size - len(line) else: n = self._bufsize @@ -244,6 +244,11 @@ class BufferedFile (object): rpos = line.find(cr_byte) if (rpos >= 0) and (rpos < pos or pos < 0): pos = rpos + if pos == -1: + #self._rbuffer = line[size:] + #line = line[:size] + self._pos += len(line) + return line if self._flags & self.FLAG_BINARY else u(line) xpos = pos + 1 if (line[pos] == cr_byte_value) and (xpos < len(line)) and (line[xpos] == linefeed_byte_value): xpos += 1 diff --git a/tests/test_file.py b/tests/test_file.py index 22a34aca..24a7fa9b 100755 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -70,13 +70,15 @@ class BufferedFileTest (unittest.TestCase): def test_2_readline(self): f = LoopbackFile('r+U') - f.write(b'First line.\nSecond line.\r\nThird line.\nFinal line non-terminated.') + f.write(b'First line.\nSecond line.\r\nThird line.\nFourth line.\nFifth line.\nFinal line non-terminated.') self.assertEqual(f.readline(), 'First line.\n') # universal newline mode should convert this linefeed: self.assertEqual(f.readline(), 'Second line.\n') # truncated line: self.assertEqual(f.readline(7), 'Third l') self.assertEqual(f.readline(), 'ine.\n') + self.assertEqual(f.readline(25), 'Fourth line.\n') + self.assertEqual(f.readline(), 'Fifth line.\n') self.assertEqual(f.readline(), 'Final line non-terminated.') self.assertEqual(f.readline(), '') f.close() |