Exemplo n.º 1
0
    def test_debug_log(self):
        app = flask.Flask(__name__)
        app.debug = True

        @app.route('/')
        def index():
            app.logger.warning('the standard library is dead')
            app.logger.debug('this is a debug statement')
            return ''

        @app.route('/exc')
        def exc():
            1/0

        with app.test_client() as c:
            with catch_stderr() as err:
                c.get('/')
                out = err.getvalue()
                self.assert_('WARNING in helpers [' in out)
                self.assert_(os.path.basename(__file__.rsplit('.', 1)[0] + '.py') in out)
                self.assert_('the standard library is dead' in out)
                self.assert_('this is a debug statement' in out)

            with catch_stderr() as err:
                try:
                    c.get('/exc')
                except ZeroDivisionError:
                    pass
                else:
                    self.assert_(False, 'debug log ate the exception')
Exemplo n.º 2
0
    def test_debug_log(self):
        app = flask.Flask(__name__)
        app.debug = True

        @app.route('/')
        def index():
            app.logger.warning('the standard library is dead')
            app.logger.debug('this is a debug statement')
            return ''

        @app.route('/exc')
        def exc():
            1 // 0

        with app.test_client() as c:
            with catch_stderr() as err:
                c.get('/')
                out = err.getvalue()
                self.assert_in('WARNING in helpers [', out)
                self.assert_in(
                    os.path.basename(__file__.rsplit('.', 1)[0] + '.py'), out)
                self.assert_in('the standard library is dead', out)
                self.assert_in('this is a debug statement', out)

            with catch_stderr() as err:
                try:
                    c.get('/exc')
                except ZeroDivisionError:
                    pass
                else:
                    self.assert_true(False, 'debug log ate the exception')
Exemplo n.º 3
0
    def test_debug_log(self):
        app = flask.Flask(__name__)
        app.debug = True

        @app.route("/")
        def index():
            app.logger.warning("the standard library is dead")
            app.logger.debug("this is a debug statement")
            return ""

        @app.route("/exc")
        def exc():
            1 / 0

        with app.test_client() as c:
            with catch_stderr() as err:
                c.get("/")
                out = err.getvalue()
                self.assert_("WARNING in helpers [" in out)
                self.assert_(os.path.basename(__file__.rsplit(".", 1)[0] + ".py") in out)
                self.assert_("the standard library is dead" in out)
                self.assert_("this is a debug statement" in out)

            with catch_stderr() as err:
                try:
                    c.get("/exc")
                except ZeroDivisionError:
                    pass
                else:
                    self.assert_(False, "debug log ate the exception")