Skip to content

Commit

Permalink
Work around wsgiref bug
Browse files Browse the repository at this point in the history
This will allow tests to pass with most recent WebTest
  • Loading branch information
kedder committed Mar 4, 2013
1 parent aafcb5f commit 310e5a8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
11 changes: 3 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@
+ open('CHANGES.txt').read()
)

# pinning version, because of some incompatibility and test failures
# see:
# http://winbot.zope.org/builders/zope.testbrowser_py_265_32/builds/619/steps/test/logs/stdio
WEBTEST = 'WebTest <= 1.3.4'

tests_require = ['zope.testing',
WEBTEST]
tests_require = ['zope.testing']

setup(
name='zope.testbrowser',
Expand Down Expand Up @@ -65,6 +59,7 @@
'zope.interface',
'zope.schema',
'pytz',
'WebTest',
],
extras_require={
'test': tests_require,
Expand All @@ -75,7 +70,7 @@
'zope.app.testing >= 3.9.0dev',
],
'wsgi': [
WEBTEST,
# BBB
]
},
include_package_data=True,
Expand Down
2 changes: 1 addition & 1 deletion src/zope/testbrowser/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ There is also a special version of the ``Browser`` class which uses
applications. It can be imported from ``zope.testbrowser.wsgi``:

>>> from zope.testbrowser.wsgi import Browser
>>> from wsgiref.simple_server import demo_app
>>> from zope.testbrowser.testing import demo_app
>>> browser = Browser('http://localhost/', wsgi_app=demo_app)
>>> print browser.contents
Hello world!
Expand Down
7 changes: 7 additions & 0 deletions src/zope/testbrowser/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""

from zope.testbrowser.connection import Response as PublisherResponse
from wsgiref.simple_server import demo_app as wsgiref_demo_app

try:
import zope.app.testing
Expand All @@ -29,3 +30,9 @@
Browser)

del have_zope_app_testing

def demo_app(environ, start_response):
"""PEP-3333 compatible demo app, that will never return unicode
"""
refout = wsgiref_demo_app(environ, start_response)
return [s if isinstance(s, bytes) else s.encode('utf-8') for s in refout]
3 changes: 2 additions & 1 deletion src/zope/testbrowser/tests/test_wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@

import unittest
from urllib import urlencode
from wsgiref.simple_server import demo_app

import zope.testbrowser.wsgi
from zope.testbrowser.ftests.wsgitestapp import WSGITestApplication

from zope.testbrowser.testing import demo_app


class SimpleLayer(zope.testbrowser.wsgi.Layer):

Expand Down

0 comments on commit 310e5a8

Please sign in to comment.