Adding a test for the debugger middleware.

This commit is contained in:
Jonathan LaCour
2012-03-15 13:51:21 -07:00
parent 638cd6cf02
commit ee1688f6b3
2 changed files with 28 additions and 1 deletions

File diff suppressed because one or more lines are too long

25
pecan/tests/test_debug.py Normal file
View File

@@ -0,0 +1,25 @@
from unittest import TestCase
from webtest import TestApp
from pecan.debug import DebugMiddleware
class TestDebugMiddleware(TestCase):
def setUp(self):
def conditional_error_app(environ, start_response):
if environ['PATH_INFO'] == '/error':
assert 1 == 2
start_response("200 OK", [('Content-type', 'text/plain')])
return ['requested page returned']
self.app = TestApp(DebugMiddleware(conditional_error_app))
def test_middleware_passes_through_when_no_exception_raised(self):
r = self.app.get('/')
assert r.status_int == 200
assert r.body == 'requested page returned'
def test_middleware_gives_stack_trace_on_errors(self):
r = self.app.get('/error', expect_errors=True)
assert r.status_int == 400
assert 'AssertionError' in r.body