Skip to content

Commit

Permalink
rework non_ascii_urls a bit to test the request environ
Browse files Browse the repository at this point in the history
add a request_log to the TestApplication
  • Loading branch information
Brian Sutherland committed Mar 22, 2013
1 parent b4cb637 commit 40395b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/zope/testbrowser/ftests/wsgitestapp.py
Expand Up @@ -29,10 +29,15 @@ class NotFound(Exception):

class WSGITestApplication(object):

def __init__(self):
self.request_log = []

def __call__(self, environ, start_response):
req = Request(environ)
self.request_log.append(req)
handler = {'/set_status.html': set_status,
'/echo.html': echo,
'/echo_one.html': echo_one,
'/redirect.html': redirect,
'/@@/testbrowser/forms.html': forms,
'/set_header.html': set_header,
Expand All @@ -43,8 +48,6 @@ def __call__(self, environ, start_response):
'/inner/path/set_cookie.html': set_cookie,
'/inner/path/get_cookie.html': get_cookie,
}.get(req.path_info)
if handler is None and req.path_info.endswith('/echo_one.html'):
handler = echo_one
if handler is None and req.path_info.startswith('/@@/testbrowser/'):
handler = handle_resource
if handler is None:
Expand Down
7 changes: 5 additions & 2 deletions src/zope/testbrowser/tests/test_wsgi.py
Expand Up @@ -98,11 +98,14 @@ def test_handle_errors(self):

def test_non_ascii_urls(self):
teststr = u'~ひらがな'
url = "http://localhost/%s/echo_one.html?var=PATH_INFO" % url_quote(teststr.encode('utf-8'))
url = "http://localhost/%s" % url_quote(teststr.encode('utf-8'))
app = WSGITestApplication()
browser = zope.testbrowser.wsgi.Browser(wsgi_app=app)
browser.handleErrors = False
browser.raiseHttpErrors = False
browser.open(url)
req = app.request_log[0]
self.assertEqual(req.url, url)
self.assertEqual(req.path_info, u'/' + teststr)

def test_binary_content_type(self):
# regression during webtest porting
Expand Down

0 comments on commit 40395b2

Please sign in to comment.