summaryrefslogtreecommitdiff
path: root/tests/test_exceptions/test_httpexceptions.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-04-22 02:33:32 +0200
committerVictor Stinner <victor.stinner@gmail.com>2015-04-22 02:33:32 +0200
commit3026086c19b45382d5ceca778a5458233b485ce9 (patch)
treea58fb49cd65f9b7ff24029aeb4dfaccd657128dd /tests/test_exceptions/test_httpexceptions.py
parent3e25cb1adbf0dce96f49a270d07028550b15e33c (diff)
parentb9ceb0a57e2c48f95e94693da5f3f4b86fbc3bff (diff)
downloadpaste-3026086c19b45382d5ceca778a5458233b485ce9.tar.gz
Merged in mfrobben/paste (pull request #21)
Fix bad reference to iterator variable
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')