@@ -563,6 +563,33 @@ def testFailingHELO(self):
563563 HOST , self .port , 'localhost' , 3 )
564564
565565
566+ @unittest .skipUnless (threading , 'Threading required for this test.' )
567+ class TooLongLineTests (unittest .TestCase ):
568+ respdata = b'250 OK' + (b'.' * smtplib ._MAXLINE * 2 ) + b'\n '
569+
570+ def setUp (self ):
571+ self .old_stdout = sys .stdout
572+ self .output = io .StringIO ()
573+ sys .stdout = self .output
574+
575+ self .evt = threading .Event ()
576+ self .sock = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
577+ self .sock .settimeout (15 )
578+ self .port = support .bind_port (self .sock )
579+ servargs = (self .evt , self .respdata , self .sock )
580+ threading .Thread (target = server , args = servargs ).start ()
581+ self .evt .wait ()
582+ self .evt .clear ()
583+
584+ def tearDown (self ):
585+ self .evt .wait ()
586+ sys .stdout = self .old_stdout
587+
588+ def testLineTooLong (self ):
589+ self .assertRaises (smtplib .SMTPResponseException , smtplib .SMTP ,
590+ HOST , self .port , 'localhost' , 3 )
591+
592+
566593sim_users = {
'[email protected] ' :
'John A' ,
567594568595@@ -888,7 +915,8 @@ def found_terminator(self):
888915def test_main (verbose = None ):
889916 support .run_unittest (GeneralTests , DebuggingServerTests ,
890917 NonConnectingTests ,
891- BadHELOServerTests , SMTPSimTests )
918+ BadHELOServerTests , SMTPSimTests ,
919+ TooLongLineTests )
892920
893921if __name__ == '__main__' :
894922 test_main ()
0 commit comments