(app)
| 59 | |
| 60 | |
| 61 | def test_error_handler_subclass(app): |
| 62 | class ParentException(Exception): |
| 63 | pass |
| 64 | |
| 65 | class ChildExceptionUnregistered(ParentException): |
| 66 | pass |
| 67 | |
| 68 | class ChildExceptionRegistered(ParentException): |
| 69 | pass |
| 70 | |
| 71 | @app.errorhandler(ParentException) |
| 72 | def parent_exception_handler(e): |
| 73 | assert isinstance(e, ParentException) |
| 74 | return "parent" |
| 75 | |
| 76 | @app.errorhandler(ChildExceptionRegistered) |
| 77 | def child_exception_handler(e): |
| 78 | assert isinstance(e, ChildExceptionRegistered) |
| 79 | return "child-registered" |
| 80 | |
| 81 | @app.route("/parent") |
| 82 | def parent_test(): |
| 83 | raise ParentException() |
| 84 | |
| 85 | @app.route("/child-unregistered") |
| 86 | def unregistered_test(): |
| 87 | raise ChildExceptionUnregistered() |
| 88 | |
| 89 | @app.route("/child-registered") |
| 90 | def registered_test(): |
| 91 | raise ChildExceptionRegistered() |
| 92 | |
| 93 | c = app.test_client() |
| 94 | |
| 95 | assert c.get("/parent").data == b"parent" |
| 96 | assert c.get("/child-unregistered").data == b"parent" |
| 97 | assert c.get("/child-registered").data == b"child-registered" |
| 98 | |
| 99 | |
| 100 | def test_error_handler_http_subclass(app): |
nothing calls this directly
no test coverage detected