Skip to content

Commit

Permalink
Close #6822: ftplib.FTP.storlines() expects a binary file, not a text…
Browse files Browse the repository at this point in the history
… file

Add an unit test to ensure that text files are rejectect (with TypeError)
  • Loading branch information
vstinner committed Apr 2, 2013
1 parent 6395241 commit ed3a303
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Lib/test/test_ftplib.py
Expand Up @@ -588,6 +588,10 @@ def test_storlines(self):
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])
Expand Down

0 comments on commit ed3a303

Please sign in to comment.