MCPcopy Index your code
hub / github.com/python/cpython / test_flush

Method test_flush

Lib/test/test_logging.py:1180–1206  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1178 BaseTest.tearDown(self)
1179
1180 def test_flush(self):
1181 # The memory handler flushes to its target handler based on specific
1182 # criteria (message count and message level).
1183 self.mem_logger.debug(self.next_message())
1184 self.assert_log_lines([])
1185 self.mem_logger.info(self.next_message())
1186 self.assert_log_lines([])
1187 # This will flush because the level is >= logging.WARNING
1188 self.mem_logger.warning(self.next_message())
1189 lines = [
1190 ('DEBUG', '1'),
1191 ('INFO', '2'),
1192 ('WARNING', '3'),
1193 ]
1194 self.assert_log_lines(lines)
1195 for n in (4, 14):
1196 for i in range(9):
1197 self.mem_logger.debug(self.next_message())
1198 self.assert_log_lines(lines)
1199 # This will flush because it's the 10th message since the last
1200 # flush.
1201 self.mem_logger.debug(self.next_message())
1202 lines = lines + [('DEBUG', str(i)) for i in range(n, n + 10)]
1203 self.assert_log_lines(lines)
1204
1205 self.mem_logger.debug(self.next_message())
1206 self.assert_log_lines(lines)
1207
1208 def test_flush_on_close(self):
1209 """

Callers

nothing calls this directly

Calls 6

strFunction · 0.85
next_messageMethod · 0.80
assert_log_linesMethod · 0.80
debugMethod · 0.45
infoMethod · 0.45
warningMethod · 0.45

Tested by

no test coverage detected