| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Add comprehensive unit tests for `enapter.log.configure` to verify that correct logging handlers, formatting, and levels are properly configured for different arguments (`level=None`, integer and string level names, and custom streams). Co-authored-by: rnovatorov <20299819+rnovatorov@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back! New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Sorry, something went wrong.
The original PR introduced unit tests for `enapter.log.configure` which modified the global `LOGGER` state. This global mutation leaked across tests, causing `test_standalone/test_mqtt_adapter.py` assertions like `device_channel.publish_log.assert_called()` to fail in CI. This commit resolves the issue by wrapping the `test_log/test_init.py` tests with an `autouse=True` fixture that takes a snapshot of the original logger's `level` and `handlers.copy()`, and restores them after the test executes. It also explicitly imports `enapter.log` instead of relying on the parent package. Co-authored-by: rnovatorov <20299819+rnovatorov@users.noreply.github.com>
The `test_standalone/test_mqtt_adapter.py` unit tests relied on `await asyncio.sleep(0.02)` to wait for background tasks to process queued `Log` messages and call `device_channel.publish_log`. In CI environments (specifically Python 3.13), this tight 20ms timing was occasionally too fast, causing flaky test failures (`AssertionError: Expected 'publish_log' to have been called.`). This commit increases the sleep duration in these tests to `0.1` seconds, providing a more robust buffer for the async event loop to process the queue and trigger the mock assertions. Co-authored-by: rnovatorov <20299819+rnovatorov@users.noreply.github.com>
I have successfully rebased the branch onto main. Note that there are a few pre-existing test failures on main that were brought in during the rebase, but my changes remain intact and pass locally. |
Sorry, something went wrong.
This commit introduces a comprehensive suite of unit tests for the global `enapter.log.configure` function, verifying its behavior when passed various logging level types (`None`, `str`, `int`) and custom streams. The tests are safely isolated using a global logger snapshot fixture to prevent state leakage. Additionally, this commit resolves flaky CI pipeline failures by increasing the sleep duration from `0.02s` to `0.1s` in `test_standalone/test_mqtt_adapter.py`, giving async background tasks sufficient time to process mocked calls. Co-authored-by: rnovatorov <20299819+rnovatorov@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
🎯 What: The testing gap addressed
The global log configure function in src/enapter/log/__init__.py previously lacked dedicated unit tests. It is critical to ensure that when it alters the LOGGER's level and handlers, it behaves as expected given different input arguments.
📊 Coverage: What scenarios are now tested
The new test suite comprehensively covers:
✨ Result: The improvement in test coverage
We now have full safety around the module's core configuration logic, preventing regressions in future refactoring of enapter.log.
PR created automatically by Jules for task 4294315772741945419 started by @rnovatorov