Repository navigation
test: cover init validation, util error paths and formatter fields - #138
Conversation
Add unit tests for the argument validation and error paths of the public init API, the util helpers, and the optional component and props fields of the JSON formatters. Refs #137 Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Formatter output fields tests/test_formatters_fields.py |
Tests cover configured and default component fields, fallback serialization of non-serializable values, and merging dictionary-valued props into the output root. |
Initialization and request-logging validation tests/test_init_validation.py |
Tests cover initialization errors, request instrumentation validation, request logger access before initialization, and root logger behavior when no handlers exist. |
Utility behavior tests/test_util_validation.py |
Tests cover invalid logger input, formatter updates for handlers, subclass validation, and parse_int fallback behavior. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Other
Possibly related issues
bobbui/json-logging-pythonissue 137: The pull request adds framework-free formatter, validation, and utility tests, including initialization and logger error paths. Sanic, Quart, Connexion, and Flask coverage remains outside this pull request.
Merge Risk: 
Minimal · up to 6af1b
-
No actionable issue is established in these tests; the change is ready for normal merge checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title "test: cover init validation, util error paths and formatter fields" matches the main change. The PR adds tests in three files: tests/test_init_validation.py (initialization validation and error paths), tests/test_util_validation.py (util error handling and parse_int fallback), and tests/test_formatters_fields.py (formatter component fields, non-serializable extras, and props merging). The title is specific and concise. It uses the conventional "test:" prefix and names each area. It stays under 70 characters.
-
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Part of #137 (items 3, 4 and 5; Sanic/Quart and Connexion/Flask are left for follow-up PRs).
Added
tests/test_init_validation.py: double framework init, badcustom_formatter, unknown framework,init_request_instrumentbefore init / after non-web init / with a bad formatter or DTO class,get_request_loggerbefore init,config_root_loggerwith no handlers.tests/test_util_validation.py:update_formatter_for_loggers,validate_subclass,parse_int.tests/test_formatters_fields.py: component fields,repr()fallback for non-serialisable extras,propsmerging.Tested: Python 3.14.6 on Windows;
pytest tests --ignore=tests/smoketests --ignore=tests/test_gunicorn_flask.pygives 117 passed (95 before). Smoke tests and the gunicorn test were not run.Notes
init_non_webcalled twice does not raise (non-web init leaves_current_frameworkunset), so only framework init is tested for the double-init error.BaseJSONFormatter.base_object_commonis a class-level dict written to by every formatter instance, so component settings leak between formatters; the test fixture restores it. Not changed here.get_request_logger()afterinit_flask()but before request instrumentation raisesAttributeErrorinstead of the intendedRuntimeError; fixed separately.Summary by CodeRabbit
propsvalues.