summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2014-05-16 17:13:13 -0400
committerChris McDonough <chrism@plope.com>2014-05-16 17:13:13 -0400
commit1e72f502c81998b7646e3475326d1cf85d6c18a2 (patch)
tree08f17fa1cc8dc8383bf72c415c83d36b9e791d8f
parent106b196dae40b0c49f3138d0fd2ffe0ff130a58d (diff)
downloadwaitress-1e72f502c81998b7646e3475326d1cf85d6c18a2.tar.gz
fix tests under windows
-rw-r--r--CHANGES.txt5
-rw-r--r--waitress/tests/fixtureapps/getline.py11
-rw-r--r--waitress/tests/test_functional.py5
3 files changed, 16 insertions, 5 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 9a9e6a3..a656f1e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,11 @@
Unreleased
----------
+- Fix tests under Windows. NB: to run tests under Windows, you cannot run
+ "setup.py test" or "setup.py nosetests". Instead you must run ``python.exe
+ -c "import nose; nose.main()"``. If you try to run the tests using the
+ normal method, each subprocess will attempt to run the test suite again.
+
- Give the WSGI app_iter generated when ``wsgi.file_wrapper`` is used
(ReadOnlyFileBasedBuffer) a ``close`` method. Do not call ``close`` on an
instance of such a class when it's used as a WSGI app_iter, however. This is
diff --git a/waitress/tests/fixtureapps/getline.py b/waitress/tests/fixtureapps/getline.py
index 3f3e096..7d8ae5d 100644
--- a/waitress/tests/fixtureapps/getline.py
+++ b/waitress/tests/fixtureapps/getline.py
@@ -2,13 +2,16 @@ import sys
if __name__ == '__main__':
try:
- from urllib.request import urlopen
+ from urllib.request import urlopen, URLError
except ImportError:
- from urllib2 import urlopen
+ from urllib2 import urlopen, URLError
url = sys.argv[1]
headers = {'Content-Type': 'text/plain; charset=utf-8'}
- resp = urlopen(url)
- line = resp.readline().decode('ascii') # py3
+ try:
+ resp = urlopen(url)
+ line = resp.readline().decode('ascii') # py3
+ except URLError:
+ line = 'failed to read %s' % url
sys.stdout.write(line)
sys.stdout.flush()
diff --git a/waitress/tests/test_functional.py b/waitress/tests/test_functional.py
index c066c92..020486a 100644
--- a/waitress/tests/test_functional.py
+++ b/waitress/tests/test_functional.py
@@ -38,7 +38,10 @@ class FixtureTcpWSGIServer(server.TcpWSGIServer):
# Coverage doesn't see this as it's ran in a separate process.
kw['port'] = 0 # Bind to any available port.
super(FixtureTcpWSGIServer, self).__init__(application, **kw)
- queue.put(self.socket.getsockname())
+ host, port = self.socket.getsockname()
+ if os.name == 'nt':
+ host = '127.0.0.1'
+ queue.put((host, port))
class SubprocessTests(object):