Skip to content
Myr

Added an testcase for subclassing of Flask to supress logging

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent b40af3c · Browse files · 1 file+46 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+46 added−0 removed

  • other:+46 added−0 removed

1 file+46 added−0 removed

added:flask/testsuite/subclassing.py+46 added
1# -*- coding: utf-8 -*-2"""3 flask.testsuite.subclassing4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~56 Test that certain behavior of flask can be customized by7 subclasses.89 :copyright: (c) 2011 by Armin Ronacher.10 :license: BSD, see LICENSE for more details.11"""12import flask13import unittest14from StringIO import StringIO15from logging import StreamHandler16from flask.testsuite import FlaskTestCase171819class FlaskSubclassingTestCase(FlaskTestCase):2021 def test_supressed_exception_logging(self):22 class SupressedFlask(flask.Flask):23 def log_exception(self, exc_info):24 pass2526 out = StringIO()27 app = SupressedFlask(__name__)28 app.logger_name = 'flask_tests/test_supressed_exception_logging'29 app.logger.addHandler(StreamHandler(out))3031 @app.route('/')32 def index():33 1/03435 rv = app.test_client().get('/')36 self.assert_equal(rv.status_code, 500)37 self.assert_('Internal Server Error' in rv.data)3839 err = out.getvalue()40 self.assert_equal(err, '')414243def suite():44 suite = unittest.TestSuite()45 suite.addTest(unittest.makeSuite(FlaskSubclassingTestCase))46 return suite