summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobey Pointer <robey@lag.net>2004-09-11 20:37:59 +0000
committerRobey Pointer <robey@lag.net>2004-09-11 20:37:59 +0000
commit0e96d4a7e2495e4409fd1d9d629a77e41043e75e (patch)
tree486db1e4fe18f6959a66bfe8cfc107dffff923c8
parent8c9add1a6beba4a6fce6febe173130d3de328be5 (diff)
[project @ Arch-1:robey@lag.net--2003-public%secsh--dev--1.0--patch-81]
more unit tests add test for BufferedFile.read(-1) and sftp.normalize().
-rwxr-xr-xtests/test_file.py19
-rwxr-xr-xtests/test_sftp.py13
2 files changed, 29 insertions, 3 deletions
diff --git a/tests/test_file.py b/tests/test_file.py
index 46e45d7a..7914a43f 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 3ff74ed5..e16b061b 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)