diff options
-rw-r--r-- | tests/test_urlparser.py | 12 | ||||
-rw-r--r-- | tests/urlparser_data/hook/app.py | 8 | ||||
-rw-r--r-- | tests/urlparser_data/hook/index.py | 7 | ||||
-rw-r--r-- | tests/urlparser_data/not_found/simple/__init__.py | 2 | ||||
-rw-r--r-- | tests/urlparser_data/not_found/user/list.py | 7 | ||||
-rw-r--r-- | tests/urlparser_data/python/simpleapp.py | 3 | ||||
-rw-r--r-- | tests/urlparser_data/python/stream.py | 6 | ||||
-rw-r--r-- | tests/urlparser_data/python/sub/simpleapp.py | 4 |
8 files changed, 30 insertions, 19 deletions
diff --git a/tests/test_urlparser.py b/tests/test_urlparser.py index d1f3377..21c210e 100644 --- a/tests/test_urlparser.py +++ b/tests/test_urlparser.py @@ -110,7 +110,7 @@ def test_xss(): app = TestApp(StaticURLParser(relative_path('find_file')), extra_environ={'HTTP_ACCEPT': 'text/html'}) res = app.get("/-->%0D<script>alert('xss')</script>", status=404) - assert '--><script>' not in res.body + assert b'--><script>' not in res.body def test_static_parser(): app = StaticURLParser(path('find_file')) @@ -118,16 +118,16 @@ def test_static_parser(): res = testapp.get('', status=301) res = testapp.get('/', status=404) res = testapp.get('/index.txt') - assert res.body.strip() == 'index1' + assert res.body.strip() == b'index1' res = testapp.get('/index.txt/foo', status=404) res = testapp.get('/test 3.html') - assert res.body.strip() == 'test 3' + assert res.body.strip() == b'test 3' res = testapp.get('/test%203.html') - assert res.body.strip() == 'test 3' + assert res.body.strip() == b'test 3' res = testapp.get('/dir with spaces/test 4.html') - assert res.body.strip() == 'test 4' + assert res.body.strip() == b'test 4' res = testapp.get('/dir%20with%20spaces/test%204.html') - assert res.body.strip() == 'test 4' + assert res.body.strip() == b'test 4' # Ensure only data under the app's root directory is accessible res = testapp.get('/../secured.txt', status=404) res = testapp.get('/dir with spaces/../../secured.txt', status=404) diff --git a/tests/urlparser_data/hook/app.py b/tests/urlparser_data/hook/app.py index a96866c..1a98013 100644 --- a/tests/urlparser_data/hook/app.py +++ b/tests/urlparser_data/hook/app.py @@ -1,5 +1,9 @@ +import six + def application(environ, start_response): start_response('200 OK', [('Content-type', 'text/html')]) - return ['user: %s' % environ['app.user']] - + body = 'user: %s' % environ['app.user'] + if six.PY3: + body = body.encode('ascii') + return [body] diff --git a/tests/urlparser_data/hook/index.py b/tests/urlparser_data/hook/index.py index 49e89f0..92f3d66 100644 --- a/tests/urlparser_data/hook/index.py +++ b/tests/urlparser_data/hook/index.py @@ -1,4 +1,9 @@ +import six + def application(environ, start_response): start_response('200 OK', [('Content-type', 'text/html')]) - return ['index: %s' % environ['app.user']] + body = 'index: %s' % environ['app.user'] + if six.PY3: + body = body.encode('ascii') + return [body] diff --git a/tests/urlparser_data/not_found/simple/__init__.py b/tests/urlparser_data/not_found/simple/__init__.py index f1e7faa..7186daa 100644 --- a/tests/urlparser_data/not_found/simple/__init__.py +++ b/tests/urlparser_data/not_found/simple/__init__.py @@ -1,3 +1,3 @@ def not_found_hook(environ, start_response): start_response('200 OK', [('Content-type', 'text/plain')]) - return ['not found'] + return [b'not found'] diff --git a/tests/urlparser_data/not_found/user/list.py b/tests/urlparser_data/not_found/user/list.py index f6228f0..fd7482f 100644 --- a/tests/urlparser_data/not_found/user/list.py +++ b/tests/urlparser_data/not_found/user/list.py @@ -1,3 +1,8 @@ +import six + def application(environ, start_response): start_response('200 OK', [('Content-type', 'text/plain')]) - return ['user: %s' % environ.get('app.user')] + body = 'user: %s' % environ.get('app.user') + if six.PY3: + body = body.encode('ascii') + return [body] diff --git a/tests/urlparser_data/python/simpleapp.py b/tests/urlparser_data/python/simpleapp.py index e13bb3e..7a36ce9 100644 --- a/tests/urlparser_data/python/simpleapp.py +++ b/tests/urlparser_data/python/simpleapp.py @@ -1,6 +1,5 @@ def application(environ, start_response): start_response('200 OK', [('Content-type', 'text/html'), ('test-header', 'TEST!')]) - return ['test1'] - + return [b'test1'] diff --git a/tests/urlparser_data/python/stream.py b/tests/urlparser_data/python/stream.py index 121b4d1..e81fd1c 100644 --- a/tests/urlparser_data/python/stream.py +++ b/tests/urlparser_data/python/stream.py @@ -1,7 +1,7 @@ def stream(): def app(environ, start_response): writer = start_response('200 OK', [('Content-type', 'text/html')]) - writer('te') - writer('st') - return ['2'] + writer(b'te') + writer(b'st') + return [b'2'] return app diff --git a/tests/urlparser_data/python/sub/simpleapp.py b/tests/urlparser_data/python/sub/simpleapp.py index ac83a56..88bd975 100644 --- a/tests/urlparser_data/python/sub/simpleapp.py +++ b/tests/urlparser_data/python/sub/simpleapp.py @@ -1,6 +1,4 @@ def application(environ, start_response): start_response('200 OK', [('Content-type', 'text/html'), ('test-header', 'TEST!')]) - return ['subsimple'] - - + return [b'subsimple'] |