diff options
author | Ian Bicking <ianb@colorstudy.com> | 2010-09-02 02:23:08 -0500 |
---|---|---|
committer | Ian Bicking <ianb@colorstudy.com> | 2010-09-02 02:23:08 -0500 |
commit | ea5aa0eed5b326fb3470362b53dfbb54295e7e2a (patch) | |
tree | 5e96730abdebf8dbee51622497d68387b22dcb0c /tests | |
parent | 4c4920adf7dde9634212ae56d7b8d37abdb92581 (diff) | |
download | paste-ea5aa0eed5b326fb3470362b53dfbb54295e7e2a.tar.gz |
Improve errors when fetching an error page: http://trac.pythonpaste.org/pythonpaste/ticket/123
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_errordocument.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/test_errordocument.py b/tests/test_errordocument.py index a3da3b8..24f3022 100644 --- a/tests/test_errordocument.py +++ b/tests/test_errordocument.py @@ -16,7 +16,7 @@ def test_ok(): assert res.header('content-type') == 'text/plain' assert res.full_status == '200 OK' assert 'requested page returned' in res - + def error_docs_app(environ, start_response): if environ['PATH_INFO'] == '/not_found': start_response("404 Not found", [('Content-type', 'text/plain')]) @@ -26,7 +26,7 @@ def error_docs_app(environ, start_response): return ['Page not found'] else: return simple_app(environ, start_response) - + def test_error_docs_app(): app = TestApp(error_docs_app) res = app.get('') @@ -42,7 +42,7 @@ def test_error_docs_app(): assert res.full_status == '404 Not found' assert 'Not found' in res -def test_forward(): +def test_forward(): app = forward(error_docs_app, codes={404:'/error'}) app = TestApp(RecursiveMiddleware(app)) res = app.get('') @@ -58,11 +58,11 @@ def test_forward(): assert res.full_status == '404 Not found' # Note changed response assert 'Page not found' in res - + def auth_required_app(environ, start_response): start_response('401 Unauthorized', [('content-type', 'text/plain'), ('www-authenticate', 'Basic realm="Foo"')]) return ['Sign in!'] - + def auth_docs_app(environ, start_response): if environ['PATH_INFO'] == '/auth': return auth_required_app(environ, start_response) @@ -81,3 +81,12 @@ def test_auth_docs_app(): assert res.header('content-type') == 'text/html' assert res.header('www-authenticate') == 'Basic realm="Foo"' assert res.body == '<html>Login!</html>' + +def test_bad_error(): + def app(environ, start_response): + start_response('404 Not Found', [('content-type', 'text/plain')]) + return ['not found'] + app = forward(app, {404: '/404.html'}) + app = TestApp(app) + resp = app.get('/test', expect_errors=True) + print resp |