@@ -245,15 +245,17 @@ def get_output_without_xpeer(self):
245245
246246 def testBasic (self ):
247247 # connect
248- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
248+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
249+ timeout = support .LOOPBACK_TIMEOUT )
249250 smtp .quit ()
250251
251252 def testSourceAddress (self ):
252253 # connect
253254 src_port = support .find_unused_port ()
254255 try :
255256 smtp = smtplib .SMTP (self .host , self .port , local_hostname = 'localhost' ,
256- timeout = 3 , source_address = (self .host , src_port ))
257+ timeout = support .LOOPBACK_TIMEOUT ,
258+ source_address = (self .host , src_port ))
257259 self .addCleanup (smtp .close )
258260 self .assertEqual (smtp .source_address , (self .host , src_port ))
259261 self .assertEqual (smtp .local_hostname , 'localhost' )
@@ -264,38 +266,43 @@ def testSourceAddress(self):
264266 raise
265267
266268 def testNOOP (self ):
267- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
269+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
270+ timeout = support .LOOPBACK_TIMEOUT )
268271 self .addCleanup (smtp .close )
269272 expected = (250 , b'OK' )
270273 self .assertEqual (smtp .noop (), expected )
271274 smtp .quit ()
272275
273276 def testRSET (self ):
274- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
277+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
278+ timeout = support .LOOPBACK_TIMEOUT )
275279 self .addCleanup (smtp .close )
276280 expected = (250 , b'OK' )
277281 self .assertEqual (smtp .rset (), expected )
278282 smtp .quit ()
279283
280284 def testELHO (self ):
281285 # EHLO isn't implemented in DebuggingServer
282- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
286+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
287+ timeout = support .LOOPBACK_TIMEOUT )
283288 self .addCleanup (smtp .close )
284289 expected = (250 , b'\n SIZE 33554432\n HELP' )
285290 self .assertEqual (smtp .ehlo (), expected )
286291 smtp .quit ()
287292
288293 def testEXPNNotImplemented (self ):
289294 # EXPN isn't implemented in DebuggingServer
290- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
295+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
296+ timeout = support .LOOPBACK_TIMEOUT )
291297 self .addCleanup (smtp .close )
292298 expected = (502 , b'EXPN not implemented' )
293299 smtp .putcmd ('EXPN' )
294300 self .assertEqual (smtp .getreply (), expected )
295301 smtp .quit ()
296302
297303 def testVRFY (self ):
298- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
304+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
305+ timeout = support .LOOPBACK_TIMEOUT )
299306 self .addCleanup (smtp .close )
300307 expected = (252 , b'Cannot VRFY user, but will accept message ' + \
301308 b'and attempt delivery' )
@@ -306,15 +313,17 @@ def testVRFY(self):
306313 def testSecondHELO (self ):
307314 # check that a second HELO returns a message that it's a duplicate
308315 # (this behavior is specific to smtpd.SMTPChannel)
309- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
316+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
317+ timeout = support .LOOPBACK_TIMEOUT )
310318 self .addCleanup (smtp .close )
311319 smtp .helo ()
312320 expected = (503 , b'Duplicate HELO/EHLO' )
313321 self .assertEqual (smtp .helo (), expected )
314322 smtp .quit ()
315323
316324 def testHELP (self ):
317- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
325+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
326+ timeout = support .LOOPBACK_TIMEOUT )
318327 self .addCleanup (smtp .close )
319328 self .assertEqual (smtp .help (), b'Supported commands: EHLO HELO MAIL ' + \
320329 b'RCPT DATA RSET NOOP QUIT VRFY' )
@@ -323,7 +332,8 @@ def testHELP(self):
323332 def testSend (self ):
324333 # connect and send mail
325334 m = 'A test message'
326- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
335+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
336+ timeout = support .LOOPBACK_TIMEOUT )
327337 self .addCleanup (smtp .close )
328338 smtp .sendmail ('John' , 'Sally' , m )
329339 # XXX(nnorwitz): this test is flaky and dies with a bad file descriptor
@@ -340,7 +350,8 @@ def testSend(self):
340350
341351 def testSendBinary (self ):
342352 m = b'A test message'
343- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
353+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
354+ timeout = support .LOOPBACK_TIMEOUT )
344355 self .addCleanup (smtp .close )
345356 smtp .sendmail ('John' , 'Sally' , m )
346357 # XXX (see comment in testSend)
@@ -356,7 +367,8 @@ def testSendBinary(self):
356367 def testSendNeedingDotQuote (self ):
357368 # Issue 12283
358369 m = '.A test\n .mes.sage.'
359- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
370+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
371+ timeout = support .LOOPBACK_TIMEOUT )
360372 self .addCleanup (smtp .close )
361373 smtp .sendmail ('John' , 'Sally' , m )
362374 # XXX (see comment in testSend)
@@ -371,7 +383,8 @@ def testSendNeedingDotQuote(self):
371383
372384 def testSendNullSender (self ):
373385 m = 'A test message'
374- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
386+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
387+ timeout = support .LOOPBACK_TIMEOUT )
375388 self .addCleanup (smtp .close )
376389 smtp .sendmail ('<>' , 'Sally' , m )
377390 # XXX (see comment in testSend)
@@ -389,7 +402,8 @@ def testSendNullSender(self):
389402
390403 def testSendMessage (self ):
391404 m = email .mime .text .MIMEText ('A test message' )
392- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
405+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
406+ timeout = support .LOOPBACK_TIMEOUT )
393407 self .addCleanup (smtp .close )
394408 smtp .send_message (m , from_addr = 'John' , to_addrs = 'Sally' )
395409 # XXX (see comment in testSend)
@@ -414,7 +428,8 @@ def testSendMessageWithAddresses(self):
414428 m ['To' ] = 'John'
415429 m ['CC' ] = 'Sally, Fred'
416430 m [
'Bcc' ]
= 'John Root <root@localhost>, "Dinsdale" <[email protected] >' 417- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
431+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
432+ timeout = support .LOOPBACK_TIMEOUT )
418433 self .addCleanup (smtp .close )
419434 smtp .send_message (m )
420435 # XXX (see comment in testSend)
@@ -448,7 +463,8 @@ def testSendMessageWithSomeAddresses(self):
448463 m = email .mime .text .MIMEText ('A test message' )
449464450465 m ['To' ] = 'John, Dinsdale'
451- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
466+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
467+ timeout = support .LOOPBACK_TIMEOUT )
452468 self .addCleanup (smtp .close )
453469 smtp .send_message (m )
454470 # XXX (see comment in testSend)
@@ -476,7 +492,8 @@ def testSendMessageWithSpecifiedAddresses(self):
476492 m = email .mime .text .MIMEText ('A test message' )
477493478494 m ['To' ] = 'John, Dinsdale'
479- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
495+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
496+ timeout = support .LOOPBACK_TIMEOUT )
480497 self .addCleanup (smtp .close )
481498 smtp .
send_message (
m ,
from_addr = '[email protected] ' ,
to_addrs = '[email protected] ' )
482499 # XXX (see comment in testSend)
@@ -507,7 +524,8 @@ def testSendMessageWithMultipleFrom(self):
507524 m ['From' ] = 'Bernard, Bianca'
508525509526 m ['To' ] = 'John, Dinsdale'
510- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
527+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
528+ timeout = support .LOOPBACK_TIMEOUT )
511529 self .addCleanup (smtp .close )
512530 smtp .send_message (m )
513531 # XXX (see comment in testSend)
@@ -540,7 +558,8 @@ def testSendMessageResent(self):
540558 m [
'Resent-From' ]
= '[email protected] ' 541559 m [
'Resent-To' ]
= 'Martha <[email protected] >, Jeff' 542560 m [
'Resent-Bcc' ]
= '[email protected] ' 543- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
561+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
562+ timeout = support .LOOPBACK_TIMEOUT )
544563 self .addCleanup (smtp .close )
545564 smtp .send_message (m )
546565 # XXX (see comment in testSend)
@@ -579,7 +598,8 @@ def testSendMessageMultipleResentRaises(self):
579598 m ['Resent-Date' ] = 'Thu, 2 Jan 1970 17:42:00 +0000'
580599 m [
'Resent-To' ]
= '[email protected] ' 581600 m [
'Resent-From' ]
= 'Martha <[email protected] >, Jeff' 582- smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
601+ smtp = smtplib .SMTP (HOST , self .port , local_hostname = 'localhost' ,
602+ timeout = support .LOOPBACK_TIMEOUT )
583603 self .addCleanup (smtp .close )
584604 with self .assertRaises (ValueError ):
585605 smtp .send_message (m )
@@ -1130,7 +1150,8 @@ def found_terminator(self):
11301150
11311151 def test_smtputf8_NotSupportedError_if_no_server_support (self ):
11321152 smtp = smtplib .SMTP (
1133- HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
1153+ HOST , self .port , local_hostname = 'localhost' ,
1154+ timeout = support .LOOPBACK_TIMEOUT )
11341155 self .addCleanup (smtp .close )
11351156 smtp .ehlo ()
11361157 self .assertTrue (smtp .does_esmtp )
@@ -1145,7 +1166,8 @@ def test_smtputf8_NotSupportedError_if_no_server_support(self):
11451166
11461167 def test_send_unicode_without_SMTPUTF8 (self ):
11471168 smtp = smtplib .SMTP (
1148- HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
1169+ HOST , self .port , local_hostname = 'localhost' ,
1170+ timeout = support .LOOPBACK_TIMEOUT )
11491171 self .addCleanup (smtp .close )
11501172 self .assertRaises (UnicodeEncodeError , smtp .sendmail , 'Alice' , 'Böb' , '' )
11511173 self .assertRaises (UnicodeEncodeError , smtp .mail , 'Älice' )
@@ -1158,15 +1180,16 @@ def test_send_message_error_on_non_ascii_addrs_if_no_smtputf8(self):
11581180 msg ['To' ] = 'Dinsdale'
11591181 msg ['Subject' ] = 'Nudge nudge, wink, wink \u1F60 9'
11601182 smtp = smtplib .SMTP (
1161- HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
1183+ HOST , self .port , local_hostname = 'localhost' ,
1184+ timeout = support .LOOPBACK_TIMEOUT )
11621185 self .addCleanup (smtp .close )
11631186 with self .assertRaises (smtplib .SMTPNotSupportedError ):
11641187 smtp .send_message (msg )
11651188
11661189 def test_name_field_not_included_in_envelop_addresses (self ):
11671190 smtp = smtplib .SMTP (
1168- HOST , self .port , local_hostname = 'localhost' , timeout = 3
1169- )
1191+ HOST , self .port , local_hostname = 'localhost' ,
1192+ timeout = support . LOOPBACK_TIMEOUT )
11701193 self .addCleanup (smtp .close )
11711194
11721195 message = EmailMessage ()
@@ -1242,7 +1265,8 @@ def tearDown(self):
12421265
12431266 def test_test_server_supports_extensions (self ):
12441267 smtp = smtplib .SMTP (
1245- HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
1268+ HOST , self .port , local_hostname = 'localhost' ,
1269+ timeout = support .LOOPBACK_TIMEOUT )
12461270 self .addCleanup (smtp .close )
12471271 smtp .ehlo ()
12481272 self .assertTrue (smtp .does_esmtp )
@@ -1251,7 +1275,8 @@ def test_test_server_supports_extensions(self):
12511275 def test_send_unicode_with_SMTPUTF8_via_sendmail (self ):
12521276 m = '¡a test message containing unicode!' .encode ('utf-8' )
12531277 smtp = smtplib .SMTP (
1254- HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
1278+ HOST , self .port , local_hostname = 'localhost' ,
1279+ timeout = support .LOOPBACK_TIMEOUT )
12551280 self .addCleanup (smtp .close )
12561281 smtp .sendmail ('Jőhn' , 'Sálly' , m ,
12571282 mail_options = ['BODY=8BITMIME' , 'SMTPUTF8' ])
@@ -1265,7 +1290,8 @@ def test_send_unicode_with_SMTPUTF8_via_sendmail(self):
12651290 def test_send_unicode_with_SMTPUTF8_via_low_level_API (self ):
12661291 m = '¡a test message containing unicode!' .encode ('utf-8' )
12671292 smtp = smtplib .SMTP (
1268- HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
1293+ HOST , self .port , local_hostname = 'localhost' ,
1294+ timeout = support .LOOPBACK_TIMEOUT )
12691295 self .addCleanup (smtp .close )
12701296 smtp .ehlo ()
12711297 self .assertEqual (
@@ -1301,7 +1327,8 @@ def test_send_message_uses_smtputf8_if_addrs_non_ascii(self):
13011327 oh là là, know what I mean, know what I mean?
13021328 """ )
13031329 smtp = smtplib .SMTP (
1304- HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
1330+ HOST , self .port , local_hostname = 'localhost' ,
1331+ timeout = support .LOOPBACK_TIMEOUT )
13051332 self .addCleanup (smtp .close )
13061333 self .assertEqual (smtp .send_message (msg ), {})
13071334 self .
assertEqual (
self .
serv .
last_mailfrom ,
'fő[email protected] ' )
0 commit comments