Skip to content
Myr

Fixed last commit and added test

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent f1537a9 · Browse files · 2 files+31 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+31 added−6 removed

  • other:+31 added−6 removed

2 files+31 added−6 removed

modified:flask/testsuite/regression.py+25 added
84 unmodified lines
85 with self.assert_raises(NotFound):86 safe_join('/foo', '..')878889class ExceptionTestCase(FlaskTestCase):9091 def test_aborting(self):92 class Foo(Exception):93 whatever = 4294 app = flask.Flask(__name__)95 app.testing = True96 @app.errorhandler(Foo)97 def handle_foo(e):98 return str(e.whatever)99 @app.route('/')100 def index():101 raise flask.abort(flask.redirect(flask.url_for('test')))102 @app.route('/test')103 def test():104 raise Foo()105106 with app.test_client() as c:107 rv = c.get('/')108 self.assertEqual(rv.headers['Location'], 'http://localhost/test')109 rv = c.get('/test')110 self.assertEqual(rv.data, '42')111112113def suite():114 suite = unittest.TestSuite()115 suite.addTest(unittest.makeSuite(MemoryTestCase))116 suite.addTest(unittest.makeSuite(ExceptionTestCase))117 return suite
modified:flask/app.py+6 added-6 removed
1281 unmodified lines
12821283 .. versionadded:: 0.31284 """1285 handlers = self.error_handler_spec.get(request.blueprint)1286 # Proxy exceptions don't have error codes. We want to always return1287 # those unchanged as errors1288 if e.code is None:1289 return e1290 if handlers and e.code in handlers:1291 handler = handlers[e.code]1292 else:1293 handler = self.error_handler_spec[None].get(e.code)
36 unmodified lines
13301331 # ensure not to trash sys.exc_info() at that point in case someone1332 # wants the traceback preserved in handle_http_exception. Of course1333 # we cannot prevent users from trashing it themselves in a custom1330 # trap_http_exception method so that's their fault then. Proxy1331 # exceptions generally must always be trapped (filtered out by1332 # e.code == None)1333 if isinstance(e, HTTPException) \1334 and e.code is not None \1335 and not self.trap_http_exception(e):1334 # trap_http_exception method so that's their fault then.1335 if isinstance(e, HTTPException) and not self.trap_http_exception(e):1336 return self.handle_http_exception(e)13371338 blueprint_handlers = ()1339 handlers = self.error_handler_spec.get(request.blueprint)
445 unmodified lines