From 5c12acefbb90d4328f896633b636c8e05d87a0dd Mon Sep 17 00:00:00 2001 From: David Lord Date: Mon, 5 Jun 2017 06:14:13 -0700 Subject: [PATCH] failing test --- tests/test_basic.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/test_basic.py b/tests/test_basic.py index 108c1409..d24678c2 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -980,6 +980,39 @@ def test_http_error_subclass_handling(app, client): assert client.get('/3').data == b'apple' +def test_errorhandler_precedence(app, client): + class E1(Exception): + pass + + class E2(Exception): + pass + + class E3(E1, E2): + pass + + @app.errorhandler(E2) + def handle_e2(e): + return 'E2' + + @app.errorhandler(Exception) + def handle_exception(e): + return 'Exception' + + @app.route('/E1') + def raise_e1(): + raise E1 + + @app.route('/E3') + def raise_e3(): + raise E3 + + rv = client.get('/E1') + assert rv.data == b'Exception' + + rv = client.get('/E3') + assert rv.data == b'E2' + + def test_trapping_of_bad_request_key_errors(app, client): @app.route('/fail') def fail():