@@ -569,6 +569,33 @@ def testFailingHELO(self):
569569 HOST , self .port , 'localhost' , 3 )
570570
571571
572+ @unittest .skipUnless (threading , 'Threading required for this test.' )
573+ class TooLongLineTests (unittest .TestCase ):
574+ respdata = b'250 OK' + (b'.' * smtplib ._MAXLINE * 2 ) + b'\n '
575+
576+ def setUp (self ):
577+ self .old_stdout = sys .stdout
578+ self .output = io .StringIO ()
579+ sys .stdout = self .output
580+
581+ self .evt = threading .Event ()
582+ self .sock = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
583+ self .sock .settimeout (15 )
584+ self .port = support .bind_port (self .sock )
585+ servargs = (self .evt , self .respdata , self .sock )
586+ threading .Thread (target = server , args = servargs ).start ()
587+ self .evt .wait ()
588+ self .evt .clear ()
589+
590+ def tearDown (self ):
591+ self .evt .wait ()
592+ sys .stdout = self .old_stdout
593+
594+ def testLineTooLong (self ):
595+ self .assertRaises (smtplib .SMTPResponseException , smtplib .SMTP ,
596+ HOST , self .port , 'localhost' , 3 )
597+
598+
572599sim_users = {
'[email protected] ' :
'John A' ,
573600574601@@ -885,7 +912,8 @@ def found_terminator(self):
885912def test_main (verbose = None ):
886913 support .run_unittest (GeneralTests , DebuggingServerTests ,
887914 NonConnectingTests ,
888- BadHELOServerTests , SMTPSimTests )
915+ BadHELOServerTests , SMTPSimTests ,
916+ TooLongLineTests )
889917
890918if __name__ == '__main__' :
891919 test_main ()
0 commit comments