summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-04-02 22:13:27 +0200
committerVictor Stinner <victor.stinner@gmail.com>2013-04-02 22:13:27 +0200
commitf02f584e1daabed1d25ac13e1bb4f8eadf5ecc7f (patch)
tree02af8bf0a4be60ee60ed5e7cd6cf25e1470df929
parentda2247c901ca809c64358a1960f32c7bc46bfae8 (diff)
downloadcpython-f02f584e1daabed1d25ac13e1bb4f8eadf5ecc7f.tar.gz
Close #6822: ftplib.FTP.storlines() expects a binary file, not a text file
Add an unit test to ensure that text files are rejectect (with TypeError)
-rw-r--r--Lib/test/test_ftplib.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py
index 824b7c123b..6a6516517f 100644
--- a/Lib/test/test_ftplib.py
+++ b/Lib/test/test_ftplib.py
@@ -588,6 +588,10 @@ class TestFTPClass(TestCase):
self.client.storlines('stor foo', f, callback=lambda x: flag.append(None))
self.assertTrue(flag)
+ f = io.StringIO(RETR_DATA.replace('\r\n', '\n'))
+ # storlines() expects a binary file, not a text file
+ self.assertRaises(TypeError, self.client.storlines, 'stor foo', f)
+
def test_nlst(self):
self.client.nlst()
self.assertEqual(self.client.nlst(), NLST_DATA.split('\r\n')[:-1])