Summary
Add a LoggingPlugin that intercepts logging.Logger calls and records them as assertable interactions.
Motivation
Asserting that code emits the right log messages at the right levels is a very common testing need. Currently there's no bigfoot plugin for this. Test authors either use caplog (pytest) with manual assertions that lack bigfoot's certainty guarantees, or don't assert logs at all.
Proposed Design
- Intercepts
logging.Logger.log, info, warning, error, critical, debug
- Records interactions with fields:
level, message, logger_name
- Simple state machine: one step per log call
- Assertion helpers:
assert_log(level, message, logger_name) or per-level helpers like assert_warning(message)
- No extra dependencies (stdlib only)
- Proxy:
bigfoot.log_mock
Why it fits bigfoot
Logging is a side effect of code execution. bigfoot's model is "every external call intercepted, queued, and verified." Log calls are external calls to the logging subsystem that can and should be verified with the same certainty guarantees as HTTP calls or database queries.
Acceptance Criteria
Summary
Add a
LoggingPluginthat interceptslogging.Loggercalls and records them as assertable interactions.Motivation
Asserting that code emits the right log messages at the right levels is a very common testing need. Currently there's no bigfoot plugin for this. Test authors either use
caplog(pytest) with manual assertions that lack bigfoot's certainty guarantees, or don't assert logs at all.Proposed Design
logging.Logger.log,info,warning,error,critical,debuglevel,message,logger_nameassert_log(level, message, logger_name)or per-level helpers likeassert_warning(message)bigfoot.log_mockWhy it fits bigfoot
Logging is a side effect of code execution. bigfoot's model is "every external call intercepted, queued, and verified." Log calls are external calls to the logging subsystem that can and should be verified with the same certainty guarantees as HTTP calls or database queries.
Acceptance Criteria
LoggingPluginwithassert_log()and per-level assertion helpers