summaryrefslogtreecommitdiff
path: root/tests/test_exceptions
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_exceptions')
-rw-r--r--tests/test_exceptions/test_error_middleware.py20
-rw-r--r--tests/test_exceptions/test_formatter.py3
-rw-r--r--tests/test_exceptions/test_httpexceptions.py21
3 files changed, 21 insertions, 23 deletions
diff --git a/tests/test_exceptions/test_error_middleware.py b/tests/test_exceptions/test_error_middleware.py
index a34de73..95ab177 100644
--- a/tests/test_exceptions/test_error_middleware.py
+++ b/tests/test_exceptions/test_error_middleware.py
@@ -19,7 +19,7 @@ def do_request(app, expect_status=500):
def clear_middleware(app):
"""
The fixture sets paste.throw_errors, which suppresses exactly what
- we want to test in this case. This wrapper also strips exc_info
+ we want to test in this case. This wrapper also strips exc_info
on the *first* call to start_response (but not the second, or
subsequent calls.
"""
@@ -34,7 +34,7 @@ def clear_middleware(app):
del environ['paste.throw_errors']
return app(environ, replacement)
return clear_throw_errors
-
+
############################################################
## Applications that raise exceptions
@@ -57,7 +57,7 @@ def after_start_response_app(environ, start_response):
def iter_app(environ, start_response):
start_response("200 OK", [('Content-type', 'text/plain')])
- return yielder(['this', ' is ', ' a', None])
+ return yielder([b'this', b' is ', b' a', None])
def yielder(args):
for arg in args:
@@ -73,15 +73,17 @@ def test_makes_exception():
res = do_request(bad_app)
assert '<html' in res
res = strip_html(str(res))
- #print res
- assert 'bad_app() takes no arguments (2 given' in res
+ if six.PY3:
+ assert 'bad_app() takes 0 positional arguments but 2 were given' in res
+ else:
+ assert 'bad_app() takes no arguments (2 given' in res, repr(res)
assert 'iterator = application(environ, start_response_wrapper)' in res
assert 'paste.lint' in res
assert 'paste.exceptions.errormiddleware' in res
def test_unicode_exception():
res = do_request(unicode_bad_app)
-
+
def test_start_res():
res = do_request(start_response_app)
@@ -101,7 +103,7 @@ def test_iter_app():
#print res
assert 'None raises error' in res
assert 'yielder' in res
-
-
-
+
+
+
diff --git a/tests/test_exceptions/test_formatter.py b/tests/test_exceptions/test_formatter.py
index 3d5bdad..9c53a9a 100644
--- a/tests/test_exceptions/test_formatter.py
+++ b/tests/test_exceptions/test_formatter.py
@@ -1,10 +1,8 @@
from paste.exceptions import formatter
from paste.exceptions import collector
-from paste.util.quoting import strip_html
import sys
import os
import difflib
-import re
class Mock(object):
def __init__(self, **kw):
@@ -153,7 +151,6 @@ def test_hide_after():
raise_error)
except:
result = format(f)
- print(strip_html(result).encode('ascii', 'replace'))
assert 'AABB' in result
assert 'CCDD' not in result
assert 'raise_error' in result
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')