summaryrefslogtreecommitdiff
path: root/Lib/test/test_smtplib.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2014-02-10 22:11:21 +0100
committerGeorg Brandl <georg@python.org>2014-02-10 22:11:21 +0100
commitb38b5c43c710da8fd6034d1dab631c5b020652bf (patch)
tree567e29cd2f5fe5bfb48bce00109321cd29ae1bff /Lib/test/test_smtplib.py
parent6093a125ee900738a1840afb6980ec426cacad68 (diff)
downloadcpython-git-b38b5c43c710da8fd6034d1dab631c5b020652bf.tar.gz
merge with 3.3
Diffstat (limited to 'Lib/test/test_smtplib.py')
-rw-r--r--Lib/test/test_smtplib.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index 39bf7ae3b4..3f7b9b4175 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -563,6 +563,33 @@ class BadHELOServerTests(unittest.TestCase):
HOST, self.port, 'localhost', 3)
+@unittest.skipUnless(threading, 'Threading required for this test.')
+class TooLongLineTests(unittest.TestCase):
+ respdata = b'250 OK' + (b'.' * smtplib._MAXLINE * 2) + b'\n'
+
+ def setUp(self):
+ self.old_stdout = sys.stdout
+ self.output = io.StringIO()
+ sys.stdout = self.output
+
+ self.evt = threading.Event()
+ self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.sock.settimeout(15)
+ self.port = support.bind_port(self.sock)
+ servargs = (self.evt, self.respdata, self.sock)
+ threading.Thread(target=server, args=servargs).start()
+ self.evt.wait()
+ self.evt.clear()
+
+ def tearDown(self):
+ self.evt.wait()
+ sys.stdout = self.old_stdout
+
+ def testLineTooLong(self):
+ self.assertRaises(smtplib.SMTPResponseException, smtplib.SMTP,
+ HOST, self.port, 'localhost', 3)
+
+
sim_users = {'Mr.A@somewhere.com':'John A',
'Ms.B@xn--fo-fka.com':'Sally B',
'Mrs.C@somewhereesle.com':'Ruth C',
@@ -888,7 +915,8 @@ class SMTPSimTests(unittest.TestCase):
def test_main(verbose=None):
support.run_unittest(GeneralTests, DebuggingServerTests,
NonConnectingTests,
- BadHELOServerTests, SMTPSimTests)
+ BadHELOServerTests, SMTPSimTests,
+ TooLongLineTests)
if __name__ == '__main__':
test_main()