summaryrefslogtreecommitdiff
path: root/tests/test_exceptions/test_httpexceptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_exceptions/test_httpexceptions.py')
-rw-r--r--tests/test_exceptions/test_httpexceptions.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/tests/test_exceptions/test_httpexceptions.py b/tests/test_exceptions/test_httpexceptions.py
index 08e23d4..24e00dd 100644
--- a/tests/test_exceptions/test_httpexceptions.py
+++ b/tests/test_exceptions/test_httpexceptions.py
@@ -8,8 +8,8 @@ Regression Test Suite
"""
from nose.tools import assert_raises
from paste.httpexceptions import *
-from paste.wsgilib import raw_interactive
from paste.response import header_value
+import six
def test_HTTPMove():
@@ -30,8 +30,8 @@ def test_badapp():
start_response("200 OK",[])
raise HTTPBadRequest("Do not do this at home.")
newapp = HTTPExceptionHandler(badapp)
- assert 'Bad Request' in ''.join(newapp({'HTTP_ACCEPT': 'text/html'},
- (lambda a, b, c=None: None)))
+ assert b'Bad Request' in b''.join(newapp({'HTTP_ACCEPT': 'text/html'},
+ (lambda a, b, c=None: None)))
def test_unicode():
""" verify unicode output """
@@ -40,10 +40,10 @@ def test_unicode():
start_response("200 OK",[])
raise HTTPBadRequest(tstr)
newapp = HTTPExceptionHandler(badapp)
- assert tstr.encode("utf-8") in ''.join(newapp({'HTTP_ACCEPT':
+ assert tstr.encode("utf-8") in b''.join(newapp({'HTTP_ACCEPT':
'text/html'},
(lambda a, b, c=None: None)))
- assert tstr.encode("utf-8") in ''.join(newapp({'HTTP_ACCEPT':
+ assert tstr.encode("utf-8") in b''.join(newapp({'HTTP_ACCEPT':
'text/plain'},
(lambda a, b, c=None: None)))
@@ -67,15 +67,14 @@ def test_redapp():
raise HTTPFound("/bing/foo")
app = HTTPExceptionHandler(redapp)
result = list(app({'HTTP_ACCEPT': 'text/html'},saveit))
- assert '<a href="/bing/foo">' in result[0]
+ assert b'<a href="/bing/foo">' in result[0]
assert "302 Found" == saved[0][0]
- assert "text/html" == header_value(saved[0][1], 'content-type')
+ if six.PY3:
+ assert "text/html; charset=utf8" == header_value(saved[0][1], 'content-type')
+ else:
+ assert "text/html" == header_value(saved[0][1], 'content-type')
assert "/bing/foo" == header_value(saved[0][1],'location')
result = list(app({'HTTP_ACCEPT': 'text/plain'},saveit))
- print(result[0] == (
- '302 Found\n'
- 'This resource was found at /bing/foo;\n'
- 'you should be redirected automatically.\n'))
assert "text/plain; charset=utf8" == header_value(saved[1][1],'content-type')
assert "/bing/foo" == header_value(saved[1][1],'location')