|
|
@ -980,6 +980,39 @@ def test_http_error_subclass_handling(app, client): |
|
|
|
assert client.get('/3').data == b'apple' |
|
|
|
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): |
|
|
|
def test_trapping_of_bad_request_key_errors(app, client): |
|
|
|
@app.route('/fail') |
|
|
|
@app.route('/fail') |
|
|
|
def fail(): |
|
|
|
def fail(): |
|
|
|