(Merge 3.3) 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)
This commit is contained in:
Victor Stinner 2013-04-02 22:13:49 +02:00
commit 4489e927a6
1 changed files with 4 additions and 0 deletions

View 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])