[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().
This commit is contained in:
parent
8c9add1a6b
commit
0e96d4a7e2
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue