@@ -245,15 +245,17 @@ def get_output_without_xpeer(self):
245
245
246
246
def testBasic (self ):
247
247
# 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 )
249
250
smtp .quit ()
250
251
251
252
def testSourceAddress (self ):
252
253
# connect
253
254
src_port = support .find_unused_port ()
254
255
try :
255
256
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 ))
257
259
self .addCleanup (smtp .close )
258
260
self .assertEqual (smtp .source_address , (self .host , src_port ))
259
261
self .assertEqual (smtp .local_hostname , 'localhost' )
@@ -264,38 +266,43 @@ def testSourceAddress(self):
264
266
raise
265
267
266
268
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 )
268
271
self .addCleanup (smtp .close )
269
272
expected = (250 , b'OK' )
270
273
self .assertEqual (smtp .noop (), expected )
271
274
smtp .quit ()
272
275
273
276
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 )
275
279
self .addCleanup (smtp .close )
276
280
expected = (250 , b'OK' )
277
281
self .assertEqual (smtp .rset (), expected )
278
282
smtp .quit ()
279
283
280
284
def testELHO (self ):
281
285
# 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 )
283
288
self .addCleanup (smtp .close )
284
289
expected = (250 , b'\n SIZE 33554432\n HELP' )
285
290
self .assertEqual (smtp .ehlo (), expected )
286
291
smtp .quit ()
287
292
288
293
def testEXPNNotImplemented (self ):
289
294
# 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 )
291
297
self .addCleanup (smtp .close )
292
298
expected = (502 , b'EXPN not implemented' )
293
299
smtp .putcmd ('EXPN' )
294
300
self .assertEqual (smtp .getreply (), expected )
295
301
smtp .quit ()
296
302
297
303
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 )
299
306
self .addCleanup (smtp .close )
300
307
expected = (252 , b'Cannot VRFY user, but will accept message ' + \
301
308
b'and attempt delivery' )
@@ -306,15 +313,17 @@ def testVRFY(self):
306
313
def testSecondHELO (self ):
307
314
# check that a second HELO returns a message that it's a duplicate
308
315
# (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 )
310
318
self .addCleanup (smtp .close )
311
319
smtp .helo ()
312
320
expected = (503 , b'Duplicate HELO/EHLO' )
313
321
self .assertEqual (smtp .helo (), expected )
314
322
smtp .quit ()
315
323
316
324
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 )
318
327
self .addCleanup (smtp .close )
319
328
self .assertEqual (smtp .help (), b'Supported commands: EHLO HELO MAIL ' + \
320
329
b'RCPT DATA RSET NOOP QUIT VRFY' )
@@ -323,7 +332,8 @@ def testHELP(self):
323
332
def testSend (self ):
324
333
# connect and send mail
325
334
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 )
327
337
self .addCleanup (smtp .close )
328
338
smtp .sendmail ('John' , 'Sally' , m )
329
339
# XXX(nnorwitz): this test is flaky and dies with a bad file descriptor
@@ -340,7 +350,8 @@ def testSend(self):
340
350
341
351
def testSendBinary (self ):
342
352
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 )
344
355
self .addCleanup (smtp .close )
345
356
smtp .sendmail ('John' , 'Sally' , m )
346
357
# XXX (see comment in testSend)
@@ -356,7 +367,8 @@ def testSendBinary(self):
356
367
def testSendNeedingDotQuote (self ):
357
368
# Issue 12283
358
369
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 )
360
372
self .addCleanup (smtp .close )
361
373
smtp .sendmail ('John' , 'Sally' , m )
362
374
# XXX (see comment in testSend)
@@ -371,7 +383,8 @@ def testSendNeedingDotQuote(self):
371
383
372
384
def testSendNullSender (self ):
373
385
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 )
375
388
self .addCleanup (smtp .close )
376
389
smtp .sendmail ('<>' , 'Sally' , m )
377
390
# XXX (see comment in testSend)
@@ -389,7 +402,8 @@ def testSendNullSender(self):
389
402
390
403
def testSendMessage (self ):
391
404
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 )
393
407
self .addCleanup (smtp .close )
394
408
smtp .send_message (m , from_addr = 'John' , to_addrs = 'Sally' )
395
409
# XXX (see comment in testSend)
@@ -414,7 +428,8 @@ def testSendMessageWithAddresses(self):
414
428
m ['To' ] = 'John'
415
429
m ['CC' ] = 'Sally, Fred'
416
430
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 )
418
433
self .addCleanup (smtp .close )
419
434
smtp .send_message (m )
420
435
# XXX (see comment in testSend)
@@ -448,7 +463,8 @@ def testSendMessageWithSomeAddresses(self):
448
463
m = email .mime .text .MIMEText ('A test message' )
449
464
450
465
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 )
452
468
self .addCleanup (smtp .close )
453
469
smtp .send_message (m )
454
470
# XXX (see comment in testSend)
@@ -476,7 +492,8 @@ def testSendMessageWithSpecifiedAddresses(self):
476
492
m = email .mime .text .MIMEText ('A test message' )
477
493
478
494
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 )
480
497
self .addCleanup (smtp .close )
481
498
smtp .
send_message (
m ,
from_addr = '[email protected] ' ,
to_addrs = '[email protected] ' )
482
499
# XXX (see comment in testSend)
@@ -507,7 +524,8 @@ def testSendMessageWithMultipleFrom(self):
507
524
m ['From' ] = 'Bernard, Bianca'
508
525
509
526
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 )
511
529
self .addCleanup (smtp .close )
512
530
smtp .send_message (m )
513
531
# XXX (see comment in testSend)
@@ -540,7 +558,8 @@ def testSendMessageResent(self):
540
558
m [
'Resent-From' ]
= '[email protected] '
541
559
m [
'Resent-To' ]
= 'Martha <[email protected] >, Jeff'
542
560
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 )
544
563
self .addCleanup (smtp .close )
545
564
smtp .send_message (m )
546
565
# XXX (see comment in testSend)
@@ -579,7 +598,8 @@ def testSendMessageMultipleResentRaises(self):
579
598
m ['Resent-Date' ] = 'Thu, 2 Jan 1970 17:42:00 +0000'
580
599
m [
'Resent-To' ]
= '[email protected] '
581
600
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 )
583
603
self .addCleanup (smtp .close )
584
604
with self .assertRaises (ValueError ):
585
605
smtp .send_message (m )
@@ -1130,7 +1150,8 @@ def found_terminator(self):
1130
1150
1131
1151
def test_smtputf8_NotSupportedError_if_no_server_support (self ):
1132
1152
smtp = smtplib .SMTP (
1133
- HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
1153
+ HOST , self .port , local_hostname = 'localhost' ,
1154
+ timeout = support .LOOPBACK_TIMEOUT )
1134
1155
self .addCleanup (smtp .close )
1135
1156
smtp .ehlo ()
1136
1157
self .assertTrue (smtp .does_esmtp )
@@ -1145,7 +1166,8 @@ def test_smtputf8_NotSupportedError_if_no_server_support(self):
1145
1166
1146
1167
def test_send_unicode_without_SMTPUTF8 (self ):
1147
1168
smtp = smtplib .SMTP (
1148
- HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
1169
+ HOST , self .port , local_hostname = 'localhost' ,
1170
+ timeout = support .LOOPBACK_TIMEOUT )
1149
1171
self .addCleanup (smtp .close )
1150
1172
self .assertRaises (UnicodeEncodeError , smtp .sendmail , 'Alice' , 'Böb' , '' )
1151
1173
self .assertRaises (UnicodeEncodeError , smtp .mail , 'Älice' )
@@ -1158,15 +1180,16 @@ def test_send_message_error_on_non_ascii_addrs_if_no_smtputf8(self):
1158
1180
msg ['To' ] = 'Dinsdale'
1159
1181
msg ['Subject' ] = 'Nudge nudge, wink, wink \u1F60 9'
1160
1182
smtp = smtplib .SMTP (
1161
- HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
1183
+ HOST , self .port , local_hostname = 'localhost' ,
1184
+ timeout = support .LOOPBACK_TIMEOUT )
1162
1185
self .addCleanup (smtp .close )
1163
1186
with self .assertRaises (smtplib .SMTPNotSupportedError ):
1164
1187
smtp .send_message (msg )
1165
1188
1166
1189
def test_name_field_not_included_in_envelop_addresses (self ):
1167
1190
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 )
1170
1193
self .addCleanup (smtp .close )
1171
1194
1172
1195
message = EmailMessage ()
@@ -1242,7 +1265,8 @@ def tearDown(self):
1242
1265
1243
1266
def test_test_server_supports_extensions (self ):
1244
1267
smtp = smtplib .SMTP (
1245
- HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
1268
+ HOST , self .port , local_hostname = 'localhost' ,
1269
+ timeout = support .LOOPBACK_TIMEOUT )
1246
1270
self .addCleanup (smtp .close )
1247
1271
smtp .ehlo ()
1248
1272
self .assertTrue (smtp .does_esmtp )
@@ -1251,7 +1275,8 @@ def test_test_server_supports_extensions(self):
1251
1275
def test_send_unicode_with_SMTPUTF8_via_sendmail (self ):
1252
1276
m = '¡a test message containing unicode!' .encode ('utf-8' )
1253
1277
smtp = smtplib .SMTP (
1254
- HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
1278
+ HOST , self .port , local_hostname = 'localhost' ,
1279
+ timeout = support .LOOPBACK_TIMEOUT )
1255
1280
self .addCleanup (smtp .close )
1256
1281
smtp .sendmail ('Jőhn' , 'Sálly' , m ,
1257
1282
mail_options = ['BODY=8BITMIME' , 'SMTPUTF8' ])
@@ -1265,7 +1290,8 @@ def test_send_unicode_with_SMTPUTF8_via_sendmail(self):
1265
1290
def test_send_unicode_with_SMTPUTF8_via_low_level_API (self ):
1266
1291
m = '¡a test message containing unicode!' .encode ('utf-8' )
1267
1292
smtp = smtplib .SMTP (
1268
- HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
1293
+ HOST , self .port , local_hostname = 'localhost' ,
1294
+ timeout = support .LOOPBACK_TIMEOUT )
1269
1295
self .addCleanup (smtp .close )
1270
1296
smtp .ehlo ()
1271
1297
self .assertEqual (
@@ -1301,7 +1327,8 @@ def test_send_message_uses_smtputf8_if_addrs_non_ascii(self):
1301
1327
oh là là, know what I mean, know what I mean?
1302
1328
""" )
1303
1329
smtp = smtplib .SMTP (
1304
- HOST , self .port , local_hostname = 'localhost' , timeout = 3 )
1330
+ HOST , self .port , local_hostname = 'localhost' ,
1331
+ timeout = support .LOOPBACK_TIMEOUT )
1305
1332
self .addCleanup (smtp .close )
1306
1333
self .assertEqual (smtp .send_message (msg ), {})
1307
1334
self .
assertEqual (
self .
serv .
last_mailfrom ,
'fő[email protected] ' )
0 commit comments