MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_flush_on_close

Method test_flush_on_close

Lib/test/test_logging.py:1194–1222  ·  view source on GitHub ↗

Test that the flush-on-close configuration works as expected.

(self)

Source from the content-addressed store, hash-verified

1192 self.assert_log_lines(lines)
1193
1194 def test_flush_on_close(self):
1195 """
1196 Test that the flush-on-close configuration works as expected.
1197 """
1198 self.mem_logger.debug(self.next_message())
1199 self.assert_log_lines([])
1200 self.mem_logger.info(self.next_message())
1201 self.assert_log_lines([])
1202 self.mem_logger.removeHandler(self.mem_hdlr)
1203 # Default behaviour is to flush on close. Check that it happens.
1204 self.mem_hdlr.close()
1205 lines = [
1206 ('DEBUG', '1'),
1207 ('INFO', '2'),
1208 ]
1209 self.assert_log_lines(lines)
1210 # Now configure for flushing not to be done on close.
1211 self.mem_hdlr = logging.handlers.MemoryHandler(10, logging.WARNING,
1212 self.root_hdlr,
1213 False)
1214 self.mem_logger.addHandler(self.mem_hdlr)
1215 self.mem_logger.debug(self.next_message())
1216 self.assert_log_lines(lines) # no change
1217 self.mem_logger.info(self.next_message())
1218 self.assert_log_lines(lines) # no change
1219 self.mem_logger.removeHandler(self.mem_hdlr)
1220 self.mem_hdlr.close()
1221 # assert that no new lines have been added
1222 self.assert_log_lines(lines) # no change
1223
1224 def test_shutdown_flush_on_close(self):
1225 """

Callers

nothing calls this directly

Calls 7

next_messageMethod · 0.80
assert_log_linesMethod · 0.80
removeHandlerMethod · 0.80
addHandlerMethod · 0.80
debugMethod · 0.45
infoMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected