diff options
author | Marcel Hellkamp <marc@gsites.de> | 2019-12-08 20:32:22 +0100 |
---|---|---|
committer | Marcel Hellkamp <marc@gsites.de> | 2019-12-08 20:32:22 +0100 |
commit | 1c22d42f4d5d237f7963ab39621d88a1f47973b7 (patch) | |
tree | 9a6089c606fffaadd65c03ee00e8684f27ac0683 | |
parent | e0a9278e360c4e886e3c9df0814fcb68526445f9 (diff) | |
download | bottle-1c22d42f4d5d237f7963ab39621d88a1f47973b7.tar.gz |
Added tests for #1125 fix.
-rwxr-xr-x | test/test_wsgi.py | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/test/test_wsgi.py b/test/test_wsgi.py index 2af46d4..6680f04 100755 --- a/test/test_wsgi.py +++ b/test/test_wsgi.py @@ -2,7 +2,7 @@ from __future__ import with_statement import bottle from .tools import ServerTestBase, chdir -from bottle import tob, touni +from bottle import tob, touni, HTTPResponse class TestWsgi(ServerTestBase): ''' Tests for WSGI functionality, routing and output casting (decorators) ''' @@ -58,7 +58,6 @@ class TestWsgi(ServerTestBase): for h, v in bottle.response.headerlist: self.assertFalse(h.lower() in bad, "Header %s not deleted" % h) - def get304(self): """ 304 responses must not return entity headers """ bad = ('allow', 'content-encoding', 'content-language', @@ -173,6 +172,7 @@ class TestWsgi(ServerTestBase): self.assertTrue('b=b' in c) self.assertTrue('c=c; Path=/' in c) + class TestErrorHandling(ServerTestBase): def test_error_routing(self): @@ -364,6 +364,26 @@ class TestRouteDecorator(ServerTestBase): self.assertInBody("hook_content", "/") self.assertEqual(["route", "after"], called) + def test_after_response_hook_can_set_headers(self): + """ Issue #1125 """ + + @bottle.route() + def test1(): + return "test" + @bottle.route() + def test2(): + return HTTPResponse("test", 200) + @bottle.route() + def test3(): + raise HTTPResponse("test", 200) + + @bottle.hook('after_request') + def hook(): + bottle.response.headers["X-Hook"] = 'works' + + for route in ("/test1", "/test2", "/test3"): + self.assertBody('test', route) + self.assertHeader('X-Hook', 'works', route) def test_template(self): @bottle.route(template='test {{a}} {{b}}') @@ -458,7 +478,7 @@ class TestDecorators(ServerTestBase): class TestAppShortcuts(ServerTestBase): def setUp(self): ServerTestBase.setUp(self) - + def testWithStatement(self): default = bottle.default_app() inner_app = bottle.Bottle() |