Skip to content

Commit

Permalink
Test non-ascii url-quoted urls don't raise an exception.
Browse files Browse the repository at this point in the history
This used to work in the previous incarnation of
testbrowser. It now raises a obscure exception on
python 2.7 and seems to work on python 3.

I havn't included a test of the actual results as
I've not investigated exactly what the result
should be.
  • Loading branch information
Brian Sutherland committed Mar 21, 2013
1 parent 2c514fd commit ee6d362
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/zope/testbrowser/ftests/wsgitestapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def __call__(self, environ, start_response):
'/echo.html': echo,
'/redirect.html': redirect,
'/@@/testbrowser/forms.html': forms,
'/echo_one.html': echo_one,
'/set_header.html': set_header,
'/set_cookie.html': set_cookie,
'/get_cookie.html': get_cookie,
Expand All @@ -44,6 +43,8 @@ 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
11 changes: 10 additions & 1 deletion src/zope/testbrowser/tests/test_wsgi.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2011 Zope Foundation and Contributors.
Expand All @@ -17,7 +18,7 @@
import zope.testbrowser.wsgi
from zope.testbrowser.ftests.wsgitestapp import WSGITestApplication
from zope.testbrowser.testing import demo_app
from zope.testbrowser._compat import urlencode
from zope.testbrowser._compat import urlencode, url_quote


class SimpleLayer(zope.testbrowser.wsgi.Layer):
Expand Down Expand Up @@ -95,6 +96,14 @@ def test_handle_errors(self):
browser.open('http://localhost/echo_one.html?var=wsgi.handleErrors')
self.assertEqual(browser.contents, 'False')

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

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

0 comments on commit ee6d362

Please sign in to comment.