Commit b841c382 authored by Denis Bilenko's avatar Denis Bilenko

fix some tests on Windows

- test__subprocess.py: ignore test_nonblock_remove on win32
- test__example_portforwarder.py
- test__examples.py: ignore geventsendfile.py and psycopg2 on Windows
- testrunner.py: set timeout to 3 min
  some systems have really slow DNS and test__socket_dns.py fails
- test___example_servers.py: use 127.0.0.1 instead of localhost
  helps on Windows server where DNS calls are slow for some reason
parent 5b9c9249
...@@ -11,7 +11,7 @@ import util ...@@ -11,7 +11,7 @@ import util
class Test_wsgiserver(util.TestServer): class Test_wsgiserver(util.TestServer):
server = 'wsgiserver.py' server = 'wsgiserver.py'
URL = 'http://localhost:8088' URL = 'http://127.0.0.1:8088'
not_found_message = '<h1>Not Found</h1>' not_found_message = '<h1>Not Found</h1>'
def read(self, path='/'): def read(self, path='/'):
...@@ -35,7 +35,7 @@ class Test_wsgiserver(util.TestServer): ...@@ -35,7 +35,7 @@ class Test_wsgiserver(util.TestServer):
class Test_wsgiserver_ssl(Test_wsgiserver): class Test_wsgiserver_ssl(Test_wsgiserver):
server = 'wsgiserver_ssl.py' server = 'wsgiserver_ssl.py'
URL = 'https://localhost:8443' URL = 'https://127.0.0.1:8443'
class Test_webproxy(Test_wsgiserver): class Test_webproxy(Test_wsgiserver):
......
from __future__ import with_statement from __future__ import with_statement
from gevent import monkey; monkey.patch_all() from gevent import monkey; monkey.patch_all()
import sys
import socket import socket
from time import sleep from time import sleep
...@@ -9,11 +10,14 @@ from gevent.server import StreamServer ...@@ -9,11 +10,14 @@ from gevent.server import StreamServer
import util import util
class Test_portforwarder(util.TestServer): class Test(util.TestServer):
server = 'portforwarder.py' server = 'portforwarder.py'
args = ['127.0.0.1:10011', '127.0.0.1:10012'] args = ['127.0.0.1:10011', '127.0.0.1:10012']
def after(self): def after(self):
if sys.platform == 'win32':
assert self.popen.poll() is not None
else:
self.assertEqual(self.popen.poll(), 0) self.assertEqual(self.popen.poll(), 0)
def _run_all_tests(self): def _run_all_tests(self):
...@@ -35,13 +39,24 @@ class Test_portforwarder(util.TestServer): ...@@ -35,13 +39,24 @@ class Test_portforwarder(util.TestServer):
sleep(0.1) sleep(0.1)
self.popen.send_signal(15) self.popen.send_signal(15)
sleep(0.1) sleep(0.1)
try:
conn.sendall('msg2') conn.sendall('msg2')
conn.close() conn.close()
except socket.error:
if sys.platform != 'win32':
raise
# On Windows, signal/15 kills the process rather than actually sends a signal
# so, sendall('msg2') fails with
# error: [Errno 10054] An existing connection was forcibly closed by the remote host
# XXX maybe it could be made working with CTRL_C_EVENT somehow?
with gevent.Timeout(0.1): with gevent.Timeout(0.1):
self.popen.wait() self.popen.wait()
finally: finally:
server.close() server.close()
if sys.platform == 'win32':
self.assertEqual(['msg1'], log)
else:
self.assertEqual(['msg1', 'msg2'], log) self.assertEqual(['msg1', 'msg2'], log)
......
...@@ -8,7 +8,7 @@ import util ...@@ -8,7 +8,7 @@ import util
cwd = '../examples/' cwd = '../examples/'
ignore = ['wsgiserver.py', 'wsgiserver_ssl.py', 'webproxy.py', 'webpy.py'] ignore = ['wsgiserver.py', 'wsgiserver_ssl.py', 'webproxy.py', 'webpy.py']
if sys.platform == 'win32': if sys.platform == 'win32':
ignore += ['geventsendfile'] ignore += ['geventsendfile.py', 'psycopg2_pool.py']
ignore += [x[14:] for x in glob.glob('test__example_*.py')] ignore += [x[14:] for x in glob.glob('test__example_*.py')]
default_time_range = (2, 4) default_time_range = (2, 4)
......
...@@ -107,6 +107,8 @@ class Test(greentest.TestCase): ...@@ -107,6 +107,8 @@ class Test(greentest.TestCase):
finally: finally:
p.stdout.close() p.stdout.close()
if sys.platform != 'win32':
def test_nonblock_removed(self): def test_nonblock_removed(self):
# see issue #134 # see issue #134
r, w = os.pipe() r, w = os.pipe()
......
...@@ -12,7 +12,7 @@ from gevent.pool import Pool ...@@ -12,7 +12,7 @@ from gevent.pool import Pool
import util import util
TIMEOUT = 120 TIMEOUT = 180
NWORKERS = int(os.environ.get('NWORKERS') or 8) NWORKERS = int(os.environ.get('NWORKERS') or 8)
pool = None pool = None
......
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