(app, client)
| 990 | |
| 991 | |
| 992 | def test_errorhandler_precedence(app, client): |
| 993 | class E1(Exception): |
| 994 | pass |
| 995 | |
| 996 | class E2(Exception): |
| 997 | pass |
| 998 | |
| 999 | class E3(E1, E2): |
| 1000 | pass |
| 1001 | |
| 1002 | @app.errorhandler(E2) |
| 1003 | def handle_e2(e): |
| 1004 | return "E2" |
| 1005 | |
| 1006 | @app.errorhandler(Exception) |
| 1007 | def handle_exception(e): |
| 1008 | return "Exception" |
| 1009 | |
| 1010 | @app.route("/E1") |
| 1011 | def raise_e1(): |
| 1012 | raise E1 |
| 1013 | |
| 1014 | @app.route("/E3") |
| 1015 | def raise_e3(): |
| 1016 | raise E3 |
| 1017 | |
| 1018 | rv = client.get("/E1") |
| 1019 | assert rv.data == b"Exception" |
| 1020 | |
| 1021 | rv = client.get("/E3") |
| 1022 | assert rv.data == b"E2" |
| 1023 | |
| 1024 | |
| 1025 | @pytest.mark.parametrize( |