def test_suppressed_exception_logging(): class SuppressedFlak(flak.Flak): def log_exception(self, cx, exc_info): pass out = StringIO() app = SuppressedFlak(__name__) app.logger_name = "flaktest/test_suppressed_exception_logging" app.logger.addHandler(StreamHandler(out)) @app.route("/") def index(): 1 // 0 rv = app.test_client().get("/") assert rv.status_code == 500 assert b"Internal Server Error" in rv.data err = out.getvalue() assert err == ""
def test_exception_logging(self): out = StringIO() app = Flak(__name__) app.config["LOGGER_HANDLER_POLICY"] = "never" app.logger_name = "flak_tests/test_exception_logging" app.logger.addHandler(StreamHandler(out)) @app.route("/") def index(cx): 1 // 0 rv = app.test_client().get("/") assert rv.status_code == 500 assert b"Internal Server Error" in rv.data err = out.getvalue() assert "Exception on / [GET]" in err assert "Traceback (most recent call last):" in err assert "1 // 0" in err assert "ZeroDivisionError:" in err