self.run_embedded_interpreter("test_audit_subinterpreter")
def test_audit_run_command(self):
- self.run_embedded_interpreter("test_audit_run_command", timeout=3, returncode=1)
+ self.run_embedded_interpreter("test_audit_run_command",
+ timeout=support.SHORT_TIMEOUT,
+ returncode=1)
def test_audit_run_file(self):
- self.run_embedded_interpreter("test_audit_run_file", timeout=3, returncode=1)
+ self.run_embedded_interpreter("test_audit_run_file",
+ timeout=support.SHORT_TIMEOUT,
+ returncode=1)
def test_audit_run_interactivehook(self):
startup = os.path.join(self.oldcwd, support.TESTFN) + ".py"
print("sys.__interactivehook__ = lambda: None", file=f)
try:
env = {**remove_python_envvars(), "PYTHONSTARTUP": startup}
- self.run_embedded_interpreter("test_audit_run_interactivehook", timeout=5,
+ self.run_embedded_interpreter("test_audit_run_interactivehook",
+ timeout=support.SHORT_TIMEOUT,
returncode=10, env=env)
finally:
os.unlink(startup)
print("pass", file=f)
try:
env = {**remove_python_envvars(), "PYTHONSTARTUP": startup}
- self.run_embedded_interpreter("test_audit_run_startup", timeout=5,
+ self.run_embedded_interpreter("test_audit_run_startup",
+ timeout=support.SHORT_TIMEOUT,
returncode=10, env=env)
finally:
os.unlink(startup)
def test_audit_run_stdin(self):
- self.run_embedded_interpreter("test_audit_run_stdin", timeout=3, returncode=1)
+ self.run_embedded_interpreter("test_audit_run_stdin",
+ timeout=support.SHORT_TIMEOUT,
+ returncode=1)
if __name__ == "__main__":
unittest.main()
def testBasic(self):
# smoke test
- smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
+ timeout=support.LOOPBACK_TIMEOUT)
smtp.quit()
def testEHLO(self):
- smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
+ timeout=support.LOOPBACK_TIMEOUT)
# no features should be present before the EHLO
self.assertEqual(smtp.esmtp_features, {})
smtp.quit()
def testVRFY(self):
- smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
+ timeout=support.LOOPBACK_TIMEOUT)
for addr_spec, name in sim_users.items():
expected_known = (250, bytes('%s %s' %
smtp.quit()
def testEXPN(self):
- smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
+ timeout=support.LOOPBACK_TIMEOUT)
for listname, members in sim_lists.items():
users = []
def testAUTH_PLAIN(self):
self.serv.add_feature("AUTH PLAIN")
- smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
+ timeout=support.LOOPBACK_TIMEOUT)
resp = smtp.login(sim_auth[0], sim_auth[1])
self.assertEqual(resp, (235, b'Authentication Succeeded'))
smtp.close()
def testAUTH_LOGIN(self):
self.serv.add_feature("AUTH LOGIN")
- smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
+ timeout=support.LOOPBACK_TIMEOUT)
resp = smtp.login(sim_auth[0], sim_auth[1])
self.assertEqual(resp, (235, b'Authentication Succeeded'))
smtp.close()
@requires_hashdigest('md5')
def testAUTH_CRAM_MD5(self):
self.serv.add_feature("AUTH CRAM-MD5")
- smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
+ timeout=support.LOOPBACK_TIMEOUT)
resp = smtp.login(sim_auth[0], sim_auth[1])
self.assertEqual(resp, (235, b'Authentication Succeeded'))
smtp.close()
def testAUTH_multiple(self):
# Test that multiple authentication methods are tried.
self.serv.add_feature("AUTH BOGUS PLAIN LOGIN CRAM-MD5")
- smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
+ timeout=support.LOOPBACK_TIMEOUT)
resp = smtp.login(sim_auth[0], sim_auth[1])
self.assertEqual(resp, (235, b'Authentication Succeeded'))
smtp.close()
for mechanism in supported:
with self.subTest(mechanism=mechanism):
smtp = smtplib.SMTP(HOST, self.port,
- local_hostname='localhost', timeout=15)
+ local_hostname='localhost',
+ timeout=support.LOOPBACK_TIMEOUT)
smtp.ehlo('foo')
smtp.user, smtp.password = sim_auth[0], sim_auth[1]
method = 'auth_' + mechanism.lower().replace('-', '_')
def test_quit_resets_greeting(self):
smtp = smtplib.SMTP(HOST, self.port,
local_hostname='localhost',
- timeout=15)
+ timeout=support.LOOPBACK_TIMEOUT)
code, message = smtp.ehlo()
self.assertEqual(code, 250)
self.assertIn('size', smtp.esmtp_features)
# Issue 17498: make sure _rset does not raise SMTPServerDisconnected exception
def test__rest_from_mail_cmd(self):
- smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
+ timeout=support.LOOPBACK_TIMEOUT)
smtp.noop()
self.serv._SMTPchannel.mail_response = '451 Requested action aborted'
self.serv._SMTPchannel.disconnect = True
# Issue 5713: make sure close, not rset, is called if we get a 421 error
def test_421_from_mail_cmd(self):
- smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
+ timeout=support.LOOPBACK_TIMEOUT)
smtp.noop()
self.serv._SMTPchannel.mail_response = '421 closing connection'
with self.assertRaises(smtplib.SMTPSenderRefused):
self.assertEqual(self.serv._SMTPchannel.rset_count, 0)
def test_421_from_rcpt_cmd(self):
- smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
+ timeout=support.LOOPBACK_TIMEOUT)
smtp.noop()
self.serv._SMTPchannel.rcpt_response = ['250 accepted', '421 closing']
with self.assertRaises(smtplib.SMTPRecipientsRefused) as r:
else:
super().found_terminator()
self.serv.channel_class = MySimSMTPChannel
- smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
+ timeout=support.LOOPBACK_TIMEOUT)
smtp.noop()
with self.assertRaises(smtplib.SMTPDataError):
smtp.sendmail('John@foo.org', ['Sally@foo.org'], 'test message')
def testAUTH_PLAIN_initial_response_login(self):
self.serv.add_feature('AUTH PLAIN')
- smtp = smtplib.SMTP(HOST, self.port,
- local_hostname='localhost', timeout=15)
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
+ timeout=support.LOOPBACK_TIMEOUT)
smtp.login('psu', 'doesnotexist')
smtp.close()
def testAUTH_PLAIN_initial_response_auth(self):
self.serv.add_feature('AUTH PLAIN')
- smtp = smtplib.SMTP(HOST, self.port,
- local_hostname='localhost', timeout=15)
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
+ timeout=support.LOOPBACK_TIMEOUT)
smtp.user = 'psu'
smtp.password = 'doesnotexist'
code, response = smtp.auth('plain', smtp.auth_plain)
testFamily = _justAccept
def _testFamily(self):
- self.cli = socket.create_connection((HOST, self.port), timeout=30)
+ self.cli = socket.create_connection((HOST, self.port),
+ timeout=support.LOOPBACK_TIMEOUT)
self.addCleanup(self.cli.close)
self.assertEqual(self.cli.family, 2)
testSourceAddress = _justAccept
def _testSourceAddress(self):
- self.cli = socket.create_connection((HOST, self.port), timeout=30,
- source_address=('', self.source_port))
+ self.cli = socket.create_connection((HOST, self.port),
+ timeout=support.LOOPBACK_TIMEOUT,
+ source_address=('', self.source_port))
self.addCleanup(self.cli.close)
self.assertEqual(self.cli.getsockname()[1], self.source_port)
# The port number being used is sufficient to show that the bind()
def _testCount(self):
address = self.serv.getsockname()
file = open(support.TESTFN, 'rb')
- with socket.create_connection(address, timeout=2) as sock, file as file:
+ sock = socket.create_connection(address,
+ timeout=support.LOOPBACK_TIMEOUT)
+ with sock, file:
count = 5000007
meth = self.meth_from_sock(sock)
sent = meth(file, count=count)
def _testCountSmall(self):
address = self.serv.getsockname()
file = open(support.TESTFN, 'rb')
- with socket.create_connection(address, timeout=2) as sock, file as file:
+ sock = socket.create_connection(address,
+ timeout=support.LOOPBACK_TIMEOUT)
+ with sock, file:
count = 1
meth = self.meth_from_sock(sock)
sent = meth(file, count=count)
def _testWithTimeout(self):
address = self.serv.getsockname()
file = open(support.TESTFN, 'rb')
- with socket.create_connection(address, timeout=2) as sock, file as file:
+ sock = socket.create_connection(address,
+ timeout=support.LOOPBACK_TIMEOUT)
+ with sock, file:
meth = self.meth_from_sock(sock)
sent = meth(file)
self.assertEqual(sent, self.FILESIZE)