Skip to content

Commit

Permalink
fix tests under windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdonc committed May 16, 2014
1 parent 106b196 commit 1e72f50
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 7 additions & 4 deletions waitress/tests/fixtureapps/getline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

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()
5 changes: 4 additions & 1 deletion waitress/tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ def __init__(self, application, queue, **kw): # pragma: no cover
# 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):

Expand Down

0 comments on commit 1e72f50

Please sign in to comment.