| 
									
										
										
										
											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. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-02 10:35:00 +08:00
										 |  |  |     :copyright: (c) 2015 by Armin Ronacher. | 
					
						
							| 
									
										
										
										
											2011-09-06 00:52:28 +08:00
										 |  |  |     :license: BSD, see LICENSE for more details. | 
					
						
							|  |  |  | """
 | 
					
						
							|  |  |  | import flask | 
					
						
							|  |  |  | from logging import StreamHandler | 
					
						
							| 
									
										
										
										
											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.logger_name = 'flask_tests/test_suppressed_exception_logging' | 
					
						
							|  |  |  |     app.logger.addHandler(StreamHandler(out)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @app.route('/') | 
					
						
							|  |  |  |     def index(): | 
					
						
							|  |  |  |         1 // 0 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     rv = app.test_client().get('/') | 
					
						
							|  |  |  |     assert rv.status_code == 500 | 
					
						
							|  |  |  |     assert b'Internal Server Error' in rv.data | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     err = out.getvalue() | 
					
						
							|  |  |  |     assert err == '' |