Esempio n. 1
0
 def test_logger_cache(self):
     app = Flak(__name__)
     logger1 = app.logger
     assert app.logger is logger1
     assert logger1.name == __name__
     app.logger_name = __name__ + "/test_logger_cache"
     assert app.logger is not logger1
Esempio n. 2
0
    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
Esempio n. 3
0
 def test_debug_log_override(self):
     app = Flak(__name__)
     app.debug = True
     app.logger_name = "flak_tests/test_debug_log_override"
     app.logger.level = 10
     assert app.logger.level == 10