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

Method test_flat

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

Source from the content-addressed store, hash-verified

195 """Test builtin levels and their inheritance."""
196
197 def test_flat(self):
198 # Logging levels in a flat logger namespace.
199 m = self.next_message
200
201 ERR = logging.getLogger("ERR")
202 ERR.setLevel(logging.ERROR)
203 INF = logging.LoggerAdapter(logging.getLogger("INF"), {})
204 INF.setLevel(logging.INFO)
205 DEB = logging.getLogger("DEB")
206 DEB.setLevel(logging.DEBUG)
207
208 # These should log.
209 ERR.log(logging.CRITICAL, m())
210 ERR.error(m())
211
212 INF.log(logging.CRITICAL, m())
213 INF.error(m())
214 INF.warning(m())
215 INF.info(m())
216
217 DEB.log(logging.CRITICAL, m())
218 DEB.error(m())
219 DEB.warning(m())
220 DEB.info(m())
221 DEB.debug(m())
222
223 # These should not log.
224 ERR.warning(m())
225 ERR.info(m())
226 ERR.debug(m())
227
228 INF.debug(m())
229
230 self.assert_log_lines([
231 ('ERR', 'CRITICAL', '1'),
232 ('ERR', 'ERROR', '2'),
233 ('INF', 'CRITICAL', '3'),
234 ('INF', 'ERROR', '4'),
235 ('INF', 'WARNING', '5'),
236 ('INF', 'INFO', '6'),
237 ('DEB', 'CRITICAL', '7'),
238 ('DEB', 'ERROR', '8'),
239 ('DEB', 'WARNING', '9'),
240 ('DEB', 'INFO', '10'),
241 ('DEB', 'DEBUG', '11'),
242 ])
243
244 def test_nested_explicit(self):
245 # Logging levels in a nested namespace, all explicitly set.

Callers

nothing calls this directly

Calls 15

setLevelMethod · 0.95
logMethod · 0.95
errorMethod · 0.95
warningMethod · 0.95
infoMethod · 0.95
debugMethod · 0.95
getLoggerMethod · 0.80
assert_log_linesMethod · 0.80
mFunction · 0.50
setLevelMethod · 0.45
logMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected