The globals have a performance penalty which can be justified for the convinience in user code. In the app however the ctx can easily be passed through the method calls thereby reducing the performance penalty. This may affect extensions if they have subclassed the app and overridden these methods.
21 lines
480 B
Python
21 lines
480 B
Python
from io import StringIO
|
|
|
|
import flask
|
|
|
|
|
|
def test_suppressed_exception_logging():
|
|
class SuppressedFlask(flask.Flask):
|
|
def log_exception(self, exc_info, ctx):
|
|
pass
|
|
|
|
out = StringIO()
|
|
app = SuppressedFlask(__name__)
|
|
|
|
@app.route("/")
|
|
def index():
|
|
raise Exception("test")
|
|
|
|
rv = app.test_client().get("/", errors_stream=out)
|
|
assert rv.status_code == 500
|
|
assert b"Internal Server Error" in rv.data
|
|
assert not out.getvalue()
|