(app, client)
| 44 | |
| 45 | |
| 46 | def test_blueprint_specific_user_error_handling(app, client): |
| 47 | class MyDecoratorException(Exception): |
| 48 | pass |
| 49 | |
| 50 | class MyFunctionException(Exception): |
| 51 | pass |
| 52 | |
| 53 | blue = flask.Blueprint("blue", __name__) |
| 54 | |
| 55 | @blue.errorhandler(MyDecoratorException) |
| 56 | def my_decorator_exception_handler(e): |
| 57 | assert isinstance(e, MyDecoratorException) |
| 58 | return "boom" |
| 59 | |
| 60 | def my_function_exception_handler(e): |
| 61 | assert isinstance(e, MyFunctionException) |
| 62 | return "bam" |
| 63 | |
| 64 | blue.register_error_handler(MyFunctionException, my_function_exception_handler) |
| 65 | |
| 66 | @blue.route("/decorator") |
| 67 | def blue_deco_test(): |
| 68 | raise MyDecoratorException() |
| 69 | |
| 70 | @blue.route("/function") |
| 71 | def blue_func_test(): |
| 72 | raise MyFunctionException() |
| 73 | |
| 74 | app.register_blueprint(blue) |
| 75 | |
| 76 | assert client.get("/decorator").data == b"boom" |
| 77 | assert client.get("/function").data == b"bam" |
| 78 | |
| 79 | |
| 80 | def test_blueprint_app_error_handling(app, client): |
nothing calls this directly
no test coverage detected
searching dependent graphs…