Commit 61acfd7a authored by Jason Madden's avatar Jason Madden

Tweak socket timeouts for CI.

parent b57e1896
......@@ -376,10 +376,10 @@ class TestCaseMetaClass(type):
# Travis is slow and overloaded; Appveyor used to be faster, but
# as of Dec 2015 it's almost always slower and/or has much worse timer
# resolution
CI_TIMEOUT = 7
CI_TIMEOUT = 10
if PY3 and PYPY:
# pypy3 is very slow right now
CI_TIMEOUT = 10
CI_TIMEOUT = 15
LOCAL_TIMEOUT = 1
DEFAULT_LOCAL_HOST_ADDR = 'localhost'
......
......@@ -6,9 +6,10 @@ import greentest
# XXX also test: send, sendall, recvfrom, recvfrom_into, sendto
def readall(socket, address):
while socket.recv(1024):
def readall(sock, _):
while sock.recv(1024):
pass
sock.close()
class Test(greentest.TestCase):
......@@ -16,7 +17,7 @@ class Test(greentest.TestCase):
error_fatal = False
def setUp(self):
self.server = server.StreamServer(('127.0.0.1', 0), readall)
self.server = server.StreamServer((greentest.DEFAULT_BIND_ADDR, 0), readall)
self.server.start()
def tearDown(self):
......@@ -24,7 +25,7 @@ class Test(greentest.TestCase):
def test_recv_closed(self):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('localhost', self.server.server_port))
sock.connect((greentest.DEFAULT_LOCAL_HOST_ADDR, self.server.server_port))
receiver = gevent.spawn(sock.recv, 25)
try:
gevent.sleep(0.001)
......@@ -32,14 +33,14 @@ class Test(greentest.TestCase):
receiver.join(timeout=0.1)
assert receiver.ready(), receiver
self.assertEqual(receiver.value, None)
assert isinstance(receiver.exception, socket.error)
self.assertIsInstance(receiver.exception, socket.error)
self.assertEqual(receiver.exception.errno, socket.EBADF)
finally:
receiver.kill()
def test_recv_twice(self):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('localhost', self.server.server_port))
sock.connect((greentest.DEFAULT_LOCAL_HOST_ADDR, self.server.server_port))
receiver = gevent.spawn(sock.recv, 25)
try:
gevent.sleep(0.001)
......@@ -47,6 +48,7 @@ class Test(greentest.TestCase):
self.assertRaises(AssertionError, sock.recv, 25)
finally:
receiver.kill()
sock.close()
if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment