diff --git a/tests/test_file.py b/tests/test_file.py index 46e45d7..7914a43 100755 --- a/tests/test_file.py +++ b/tests/test_file.py @@ -15,7 +15,7 @@ # details. # # You should have received a copy of the GNU Lesser General Public License -# along with Foobar; if not, write to the Free Software Foundation, Inc., +# along with Paramiko; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. """ @@ -70,10 +70,13 @@ class BufferedFileTest (unittest.TestCase): def test_2_readline(self): f = LoopbackFile('r+U') - f.write('First line.\nSecond line.\r\nFinal line non-terminated.') + f.write('First line.\nSecond line.\r\nThird 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(), 'Final line non-terminated.') self.assertEqual(f.readline(), '') f.close() @@ -136,3 +139,15 @@ class BufferedFileTest (unittest.TestCase): f.write('Enough.') self.assertEqual(f.read(20), 'Too small. Enough.') f.close() + + def test_7_read_all(self): + """ + verify that read(-1) returns everything left in the file. + """ + f = LoopbackFile('r+', 16) + f.write('The first thing you need to do is open your eyes. ') + f.write('Then, you need to close them again.\n') + s = f.read(-1) + self.assertEqual(s, 'The first thing you need to do is open your eyes. Then, you ' + + 'need to close them again.\n') + f.close() diff --git a/tests/test_sftp.py b/tests/test_sftp.py index 3ff74ed..e16b061 100755 --- a/tests/test_sftp.py +++ b/tests/test_sftp.py @@ -15,7 +15,7 @@ # details. # # You should have received a copy of the GNU Lesser General Public License -# along with Foobar; if not, write to the Free Software Foundation, Inc., +# along with Paramiko; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. """ @@ -378,3 +378,14 @@ class SFTPTest (unittest.TestCase): self.assertEqual(sftp.stat('%s/hongry.txt' % FOLDER).st_size, 1024 * 1024) finally: sftp.remove('%s/hongry.txt' % FOLDER) + + def test_D_realpath(self): + """ + test that realpath is returning something non-empty and not an + error. + """ + pwd = sftp.normalize('.') + self.assert_(len(pwd) > 0) + f = sftp.normalize('./' + FOLDER) + self.assert_(len(f) > 0) + self.assert_(f == pwd + '/' + FOLDER)