2011-09-06 00:52:28 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
2014-09-01 03:54:45 +08:00
|
|
|
tests.subclassing
|
2014-09-21 22:47:38 +08:00
|
|
|
~~~~~~~~~~~~~~~~~
|
2011-09-06 00:52:28 +08:00
|
|
|
|
|
|
|
Test that certain behavior of flask can be customized by
|
|
|
|
subclasses.
|
|
|
|
|
2019-06-23 04:09:09 +08:00
|
|
|
:copyright: 2010 Pallets
|
|
|
|
:license: BSD-3-Clause
|
2011-09-06 00:52:28 +08:00
|
|
|
"""
|
2017-07-29 05:55:52 +08:00
|
|
|
|
2011-09-06 00:52:28 +08:00
|
|
|
import flask
|
2014-09-04 03:02:03 +08:00
|
|
|
|
2013-05-22 07:33:04 +08:00
|
|
|
from flask._compat import StringIO
|
2011-09-06 00:52:28 +08:00
|
|
|
|
|
|
|
|
2014-09-04 02:50:54 +08:00
|
|
|
def test_suppressed_exception_logging():
|
|
|
|
class SuppressedFlask(flask.Flask):
|
|
|
|
def log_exception(self, exc_info):
|
|
|
|
pass
|
|
|
|
|
|
|
|
out = StringIO()
|
|
|
|
app = SuppressedFlask(__name__)
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
def index():
|
2017-07-29 05:55:52 +08:00
|
|
|
raise Exception('test')
|
2014-09-04 02:50:54 +08:00
|
|
|
|
2017-07-29 05:55:52 +08:00
|
|
|
rv = app.test_client().get('/', errors_stream=out)
|
2014-09-04 02:50:54 +08:00
|
|
|
assert rv.status_code == 500
|
|
|
|
assert b'Internal Server Error' in rv.data
|
2017-07-29 05:55:52 +08:00
|
|
|
assert not out.getvalue()
|