summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-04-02 20:13:27 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-04-02 20:13:27 (GMT)
commited3a303548ba08aac44176b4566efa2f3bc0db66 (patch)
tree90cfec9f3e003b6b3a01a975004e50aa4bd77c5d /Lib
parent6395241471fb21a308d1d3595de7e704de0b97ae (diff)
downloadcpython-ed3a303548ba08aac44176b4566efa2f3bc0db66.zip
cpython-ed3a303548ba08aac44176b4566efa2f3bc0db66.tar.gz
cpython-ed3a303548ba08aac44176b4566efa2f3bc0db66.tar.bz2
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)
Diffstat (limited to 'Lib')
-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 824b7c1..6a65165 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])