@@ -537,6 +537,33 @@ def testFailingHELO(self):
537537 HOST , self .port , 'localhost' , 3 )
538538
539539
540+ @unittest .skipUnless (threading , 'Threading required for this test.' )
541+ class TooLongLineTests (unittest .TestCase ):
542+ respdata = b'250 OK' + (b'.' * smtplib ._MAXLINE * 2 ) + b'\n '
543+
544+ def setUp (self ):
545+ self .old_stdout = sys .stdout
546+ self .output = io .StringIO ()
547+ sys .stdout = self .output
548+
549+ self .evt = threading .Event ()
550+ self .sock = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
551+ self .sock .settimeout (15 )
552+ self .port = support .bind_port (self .sock )
553+ servargs = (self .evt , self .respdata , self .sock )
554+ threading .Thread (target = server , args = servargs ).start ()
555+ self .evt .wait ()
556+ self .evt .clear ()
557+
558+ def tearDown (self ):
559+ self .evt .wait ()
560+ sys .stdout = self .old_stdout
561+
562+ def testLineTooLong (self ):
563+ self .assertRaises (smtplib .SMTPResponseException , smtplib .SMTP ,
564+ HOST , self .port , 'localhost' , 3 )
565+
566+
540567sim_users = {'Mr.A@somewhere.com' :'John A' ,
541568 'Ms.B@xn--fo-fka.com' :'Sally B' ,
542569 'Mrs.C@somewhereesle.com' :'Ruth C' ,
@@ -826,7 +853,8 @@ def found_terminator(self):
826853def test_main (verbose = None ):
827854 support .run_unittest (GeneralTests , DebuggingServerTests ,
828855 NonConnectingTests ,
829- BadHELOServerTests , SMTPSimTests )
856+ BadHELOServerTests , SMTPSimTests ,
857+ TooLongLineTests )
830858
831859if __name__ == '__main__' :
832860 test_main ()
0 commit comments