MCPcopy Create free account
hub / github.com/hynek/structlog / test_captures_log_level_mapping

Method test_captures_log_level_mapping

tests/test_testing.py:114–141  ·  view source on GitHub ↗

exceptions and warn log levels are mapped like in regular loggers.

(self)

Source from the content-addressed store, hash-verified

112 ]
113
114 def test_captures_log_level_mapping(self):
115 """
116 exceptions and warn log levels are mapped like in regular loggers.
117 """
118 structlog.configure(
119 processors=[
120 structlog.stdlib.ProcessorFormatter.wrap_for_formatter,
121 ],
122 logger_factory=structlog.stdlib.LoggerFactory(),
123 wrapper_class=structlog.stdlib.BoundLogger,
124 )
125 with testing.capture_logs() as logs:
126 get_logger().exception("hello", answer=42)
127 get_logger().warn("again", answer=23)
128
129 assert [
130 {
131 "event": "hello",
132 "answer": 42,
133 "exc_info": True,
134 "log_level": "error",
135 },
136 {
137 "answer": 23,
138 "event": "again",
139 "log_level": "warning",
140 },
141 ] == logs
142
143
144class TestReturnLogger:

Callers

nothing calls this directly

Calls 3

get_loggerFunction · 0.90
exceptionMethod · 0.45
warnMethod · 0.45

Tested by

no test coverage detected