Skip to content

Commit

Permalink
Added tests for #1125 fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
defnull committed Dec 8, 2019
1 parent 01b4f9c commit 6e71430
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion test/test_wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import unittest
import bottle
from tools import ServerTestBase
from bottle import tob
from bottle import tob, HTTPResponse

class TestWsgi(ServerTestBase):
''' Tests for WSGI functionality, routing and output casting (decorators) '''
Expand Down Expand Up @@ -243,6 +243,25 @@ def hook():
self.assertBody('before', '/test')
self.assertHeader('X-Hook', 'after', '/test')

def test_after_response_hook_can_set_headers(self):
@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}}')
def test(): return dict(a=5, b=6)
Expand Down

0 comments on commit 6e71430

Please sign in to comment.