While trying to improve code coverage of unit tests in my python flask app I am encountering some code coverage gaps.
So there is a 404 error handler
@app.errorhandler(404) def page_not_found(e): app.logger.exception(e) if isinstance(e, HTTPException): return e return "404 Page not Found", 404
With this unit test
def test_404_check(app, client): res = client.get('/testof404') assert res.status_code == 404
It is passing but there is no code coverage for the errorhandler function.
How should I test this errorhandler in order to have the functions code covered?
Source: Python Questions