| 
									
										
										
										
											2020-04-04 09:33:40 +08:00
										 |  |  | from io import StringIO | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-06 00:52:28 +08:00
										 |  |  | import flask | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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__) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-07 03:39:41 +08:00
										 |  |  |     @app.route("/") | 
					
						
							| 
									
										
										
										
											2014-09-04 02:50:54 +08:00
										 |  |  |     def index(): | 
					
						
							| 
									
										
										
										
											2019-05-07 03:39:41 +08:00
										 |  |  |         raise Exception("test") | 
					
						
							| 
									
										
										
										
											2014-09-04 02:50:54 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-07 03:39:41 +08:00
										 |  |  |     rv = app.test_client().get("/", errors_stream=out) | 
					
						
							| 
									
										
										
										
											2014-09-04 02:50:54 +08:00
										 |  |  |     assert rv.status_code == 500 | 
					
						
							| 
									
										
										
										
											2019-05-07 03:39:41 +08:00
										 |  |  |     assert b"Internal Server Error" in rv.data | 
					
						
							| 
									
										
										
										
											2017-07-29 05:55:52 +08:00
										 |  |  |     assert not out.getvalue() |