Test that the flush-on-close configuration is respected by the shutdown method.
(self)
| 1236 | self.assert_log_lines(lines) # no change |
| 1237 | |
| 1238 | def test_shutdown_flush_on_close(self): |
| 1239 | """ |
| 1240 | Test that the flush-on-close configuration is respected by the |
| 1241 | shutdown method. |
| 1242 | """ |
| 1243 | self.mem_logger.debug(self.next_message()) |
| 1244 | self.assert_log_lines([]) |
| 1245 | self.mem_logger.info(self.next_message()) |
| 1246 | self.assert_log_lines([]) |
| 1247 | # Default behaviour is to flush on close. Check that it happens. |
| 1248 | logging.shutdown(handlerList=[logging.weakref.ref(self.mem_hdlr)]) |
| 1249 | lines = [ |
| 1250 | ('DEBUG', '1'), |
| 1251 | ('INFO', '2'), |
| 1252 | ] |
| 1253 | self.assert_log_lines(lines) |
| 1254 | # Now configure for flushing not to be done on close. |
| 1255 | self.mem_hdlr = logging.handlers.MemoryHandler(10, logging.WARNING, |
| 1256 | self.root_hdlr, |
| 1257 | False) |
| 1258 | self.mem_logger.addHandler(self.mem_hdlr) |
| 1259 | self.mem_logger.debug(self.next_message()) |
| 1260 | self.assert_log_lines(lines) # no change |
| 1261 | self.mem_logger.info(self.next_message()) |
| 1262 | self.assert_log_lines(lines) # no change |
| 1263 | # assert that no new lines have been added after shutdown |
| 1264 | logging.shutdown(handlerList=[logging.weakref.ref(self.mem_hdlr)]) |
| 1265 | self.assert_log_lines(lines) # no change |
| 1266 | |
| 1267 | @threading_helper.requires_working_threading() |
| 1268 | def test_race_between_set_target_and_flush(self): |
nothing calls this directly
no test coverage detected