summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorAdam Meily <meily.adam@gmail.com>2015-09-24 23:16:12 -0400
committerAdam Meily <meily.adam@gmail.com>2015-09-24 23:16:12 -0400
commit787839d3bc41cdd86905df6883b7de2b1bfb165a (patch)
tree1b88474836b6f431f6992fb6a302a02b6d053a28 /tests
parente9b9dcaa242d12f917fb44103d6493a686d409a8 (diff)
add unit tests for file-like object methods and update changelog and docs
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_file.py27
-rwxr-xr-xtests/test_sftp.py1
2 files changed, 25 insertions, 3 deletions
diff --git a/tests/test_file.py b/tests/test_file.py
index a6ff69e9..7fab6985 100755
--- a/tests/test_file.py
+++ b/tests/test_file.py
@@ -70,9 +70,9 @@ class BufferedFileTest (unittest.TestCase):
def test_2_readline(self):
f = LoopbackFile('r+U')
- f.write(b'First line.\nSecond line.\r\nThird line.\n' +
+ f.write(b'First line.\nSecond line.\r\nThird line.\n' +
b'Fourth 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')
@@ -165,7 +165,28 @@ class BufferedFileTest (unittest.TestCase):
f.write(buffer(b'Too small.'))
f.close()
+ def test_9_readable(self):
+ f = LoopbackFile('r')
+ self.assertTrue(f.readable())
+ self.assertFalse(f.writable())
+ self.assertFalse(f.seekable())
+ f.close()
+
+ def test_A_writable(self):
+ f = LoopbackFile('w')
+ self.assertTrue(f.writable())
+ self.assertFalse(f.readable())
+ self.assertFalse(f.seekable())
+ f.close()
+
+ def test_B_readinto(self):
+ data = bytearray(5)
+ f = LoopbackFile('r+')
+ f._write(b"hello")
+ f.readinto(data)
+ self.assertEqual(data, b'hello')
+ f.close()
+
if __name__ == '__main__':
from unittest import main
main()
-
diff --git a/tests/test_sftp.py b/tests/test_sftp.py
index cb8f7f84..b1829b4c 100755
--- a/tests/test_sftp.py
+++ b/tests/test_sftp.py
@@ -429,6 +429,7 @@ class SFTPTest (unittest.TestCase):
line_number += 1
pos_list.append(loc)
loc = f.tell()
+ self.assertTrue(f.seekable())
f.seek(pos_list[6], f.SEEK_SET)
self.assertEqual(f.readline(), 'Nouzilly, France.\n')
f.seek(pos_list[17], f.SEEK_SET)