test_ftplib.py: change client default timeout from 10 to 2. Hanging for 10 seconds is way too much when we expect a server response which never comes in.
This commit is contained in:
parent
a55efb3b6f
commit
b28e09421d
|
@ -123,7 +123,7 @@ class DummyFTPHandler(asynchat.async_chat):
|
|||
addr = list(map(int, arg.split(',')))
|
||||
ip = '%d.%d.%d.%d' %tuple(addr[:4])
|
||||
port = (addr[4] * 256) + addr[5]
|
||||
s = socket.create_connection((ip, port), timeout=10)
|
||||
s = socket.create_connection((ip, port), timeout=2)
|
||||
self.dtp = self.dtp_handler(s, baseclass=self)
|
||||
self.push('200 active data connection established')
|
||||
|
||||
|
@ -141,7 +141,7 @@ class DummyFTPHandler(asynchat.async_chat):
|
|||
def cmd_eprt(self, arg):
|
||||
af, ip, port = arg.split(arg[0])[1:-1]
|
||||
port = int(port)
|
||||
s = socket.create_connection((ip, port), timeout=10)
|
||||
s = socket.create_connection((ip, port), timeout=2)
|
||||
self.dtp = self.dtp_handler(s, baseclass=self)
|
||||
self.push('200 active data connection established')
|
||||
|
||||
|
@ -440,7 +440,7 @@ class TestFTPClass(TestCase):
|
|||
def setUp(self):
|
||||
self.server = DummyFTPServer((HOST, 0))
|
||||
self.server.start()
|
||||
self.client = ftplib.FTP(timeout=10)
|
||||
self.client = ftplib.FTP(timeout=2)
|
||||
self.client.connect(self.server.host, self.server.port)
|
||||
|
||||
def tearDown(self):
|
||||
|
@ -663,7 +663,7 @@ class TestFTPClass(TestCase):
|
|||
return True
|
||||
|
||||
# base test
|
||||
with ftplib.FTP(timeout=10) as self.client:
|
||||
with ftplib.FTP(timeout=2) as self.client:
|
||||
self.client.connect(self.server.host, self.server.port)
|
||||
self.client.sendcmd('noop')
|
||||
self.assertTrue(is_client_connected())
|
||||
|
@ -671,7 +671,7 @@ class TestFTPClass(TestCase):
|
|||
self.assertFalse(is_client_connected())
|
||||
|
||||
# QUIT sent inside the with block
|
||||
with ftplib.FTP(timeout=10) as self.client:
|
||||
with ftplib.FTP(timeout=2) as self.client:
|
||||
self.client.connect(self.server.host, self.server.port)
|
||||
self.client.sendcmd('noop')
|
||||
self.client.quit()
|
||||
|
@ -681,7 +681,7 @@ class TestFTPClass(TestCase):
|
|||
# force a wrong response code to be sent on QUIT: error_perm
|
||||
# is expected and the connection is supposed to be closed
|
||||
try:
|
||||
with ftplib.FTP(timeout=10) as self.client:
|
||||
with ftplib.FTP(timeout=2) as self.client:
|
||||
self.client.connect(self.server.host, self.server.port)
|
||||
self.client.sendcmd('noop')
|
||||
self.server.handler_instance.next_response = '550 error on quit'
|
||||
|
@ -779,7 +779,7 @@ class TestTLS_FTPClassMixin(TestFTPClass):
|
|||
def setUp(self):
|
||||
self.server = DummyTLS_FTPServer((HOST, 0))
|
||||
self.server.start()
|
||||
self.client = ftplib.FTP_TLS(timeout=10)
|
||||
self.client = ftplib.FTP_TLS(timeout=2)
|
||||
self.client.connect(self.server.host, self.server.port)
|
||||
# enable TLS
|
||||
self.client.auth()
|
||||
|
@ -792,7 +792,7 @@ class TestTLS_FTPClass(TestCase):
|
|||
def setUp(self):
|
||||
self.server = DummyTLS_FTPServer((HOST, 0))
|
||||
self.server.start()
|
||||
self.client = ftplib.FTP_TLS(timeout=10)
|
||||
self.client = ftplib.FTP_TLS(timeout=2)
|
||||
self.client.connect(self.server.host, self.server.port)
|
||||
|
||||
def tearDown(self):
|
||||
|
@ -852,7 +852,7 @@ class TestTLS_FTPClass(TestCase):
|
|||
self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
|
||||
keyfile=CERTFILE, context=ctx)
|
||||
|
||||
self.client = ftplib.FTP_TLS(context=ctx, timeout=10)
|
||||
self.client = ftplib.FTP_TLS(context=ctx, timeout=2)
|
||||
self.client.connect(self.server.host, self.server.port)
|
||||
self.assertNotIsInstance(self.client.sock, ssl.SSLSocket)
|
||||
self.client.auth()
|
||||
|
|
Loading…
Reference in New Issue