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

Method test_flat

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 14

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
setLevelMethod · 0.45
logMethod · 0.45
errorMethod · 0.45
warningMethod · 0.45

Tested by

no test coverage detected