]> granicus.if.org Git - python/commitdiff
Close #6822: ftplib.FTP.storlines() expects a binary file, not a text file
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 2 Apr 2013 20:13:27 +0000 (22:13 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 2 Apr 2013 20:13:27 +0000 (22:13 +0200)
Add an unit test to ensure that text files are rejectect (with TypeError)

Lib/test/test_ftplib.py

index 824b7c123b48137c495c1ca792d131956c53f2cf..6a6516517f8227f8b5721075da88c15d088d196b 100644 (file)
@@ -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])