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

Method test_stdlib_passthrough_methods

tests/test_stdlib.py:281–304  ·  view source on GitHub ↗

stdlib logger methods are also available in stdlib BoundLogger.

(self, method_name, method_args)

Source from the content-addressed store, hash-verified

279 ],
280 )
281 def test_stdlib_passthrough_methods(self, method_name, method_args):
282 """
283 stdlib logger methods are also available in stdlib BoundLogger.
284 """
285 called_stdlib_method = [False]
286
287 def validate(*args, **kw):
288 called_stdlib_method[0] = True
289
290 stdlib_logger = logging.getLogger("Test")
291 stdlib_logger_method = getattr(stdlib_logger, method_name, None)
292 if stdlib_logger_method:
293 setattr(stdlib_logger, method_name, validate)
294 bl = BoundLogger(stdlib_logger, [], {})
295 bound_logger_method = getattr(bl, method_name)
296
297 assert bound_logger_method is not None
298
299 if method_args:
300 bound_logger_method(*method_args)
301 else:
302 bound_logger_method()
303
304 assert called_stdlib_method[0] is True
305
306 def test_is_enabled_for(self):
307 """

Callers

nothing calls this directly

Calls 1

BoundLoggerClass · 0.90

Tested by

no test coverage detected