Add logging module tests and raise coverage threshold to 68%#147
Open
bedus-creation wants to merge 4 commits into
Open
Add logging module tests and raise coverage threshold to 68%#147bedus-creation wants to merge 4 commits into
bedus-creation wants to merge 4 commits into
Conversation
…to 68% Add unittest-style tests covering the logging module: LogProvider register/boot, channel and driver factories, level filtering, the Log facade, channels, drivers, handler installation, and config defaults. Raise pytest-cov fail_under from 50 to 68; total coverage is now ~71%.
Let the framework wire up logging through the normal app lifecycle instead of calling LogProvider.register() by hand. The module captures and restores the global app singleton and the root logger handlers so booting does not leak into other test modules.
bedus-creation
commented
Jul 8, 2026
bedus-creation
left a comment
Contributor
Author
There was a problem hiding this comment.
Code review — APPROVE (posted as comment; GitHub blocks self-approval on own PR)
Verified locally (from fastapi_startkit/):
tests/logging/test_logging.py: 50 passed- Full suite (
--ignore=tests/masoniteorm/postgres): 1648 passed, 7 skipped, total coverage 71.18% — clears the newfail_under = 68with ~3.2% margin - Logging module coverage: 0% → 85%
Strengths:
- Clean state hygiene:
setUpModule/tearDownModulesave and restore root-logger handlers, level, and the global app singleton;Logger.instancereset; tempfiles cleaned up;propagate=Falseon the single/syslog logger to avoid cross-talk with the installed handler. - Real behavior exercised, not just imports — factory resolution, level-severity filtering, channel delegation, driver output (stdout/file), Slack (mocked HTTP) and syslog (mocked handler), provider register/boot including the no-default-channel early return.
- No production code changed apart from the
fail_underbump.
No blocking issues. Recommended: merge.
…f-reference The Slack post test compared the posted URL to driver.slack_url — the same attribute that produced the call — so a wrong endpoint would pass. Assert the literal endpoint and the token/channel/username payload contract instead. Verified via mutation testing: corrupting slack_url now fails the test.
…mezone Fix a fixed instant on a day boundary and show two timezones produce two differently-dated daily log files on disk, driven by logging.channels.timezone. Verified via mutation testing: hardcoding UTC in BaseChannel.get_time (filename) and BaseDriver.get_time (get_time) each fails its corresponding assertion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds real unittest-style tests for the logging module and raises the pytest-cov minimum coverage threshold from 50 to 68. Ships tasks #675 and #674 together so coverage is measured with the new tests present.
Changes
tests/logging/test_logging.py— new test suite (50 tests) exercising the actual logging module:LogProviderregister/boot: factory + manager bindings, config merge, logger channel swap, early-return when no default channelChannelFactory/DriverFactoryname→class resolution and unknown lookupsBaseDriver.should_runlevel-severity filteringBaseChannel/MultiBaseChannel/StackChanneldelegation and level thresholdsLoggerfacade: level delegation,log()dispatch + fallback, caller locationLoggingManager/LoggingHandlerinstall idempotency and record forwardingmake_directory, config dataclass defaults, exception listenerpyproject.toml—fail_under50 → 68The suite installs a global
LoggingHandlerduring setup; the module fully restores root-logger and app state in teardown so no state leaks into other test modules.Verification
uv run pytest --cov --cov-report=term-missing(fromfastapi_startkit/):tests/masoniteorm/postgrestests that require a live Postgres connection (documented--ignore=tests/masoniteorm/postgres), unrelated to this change.