Repository navigation
[py] handle ERROR log level in SeleniumManager - #18287
saiyam-jain-dev wants to merge 3 commits into
Conversation
Selenium Manager outputs structured logs with severity levels (WARN, ERROR, INFO, DEBUG). In Python's _process_logs, entries with level ERROR were previously ignored. They are now forwarded to logger.error. Also update selenium_manager_tests.py: - mock Path.is_file in platform binary selection tests so the path resolution logic can be unit-tested without requiring compiled binaries for all foreign platforms to exist locally - add unit test coverage for _process_logs across all log levels
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
@saiyam-jain-dev did you run tests for this one locally? |
Signed-off-by: Saiyam Jain <jimisierra2@gmail.com>
|
@diemol Yes, all 15 tests in py/test/unit/selenium/webdriver/common/selenium_manager_tests.py pass locally, including the est_process_logs case covering WARN, ERROR, INFO, and DEBUG output. The previous CI failure was caused by a trailing blank line at the end of selenium_manager_tests.py that tripped the format check. That was fixed in commit d7c11d, and both |
Code Review by Qodo
1. Platform tests miss wrong binary paths
|
|
|
||
|
|
||
| def test_uses_windows(monkeypatch): | ||
| monkeypatch.setattr(Path, "is_file", lambda p: p.parent.name != "common") |
There was a problem hiding this comment.
1. Platform tests miss wrong binary paths 📘 Rule violation ☼ Reliability
The six platform selection tests replace Path.is_file with lambda p: p.parent.name != "common", a fake filesystem that reports any path outside a common folder as present, so _get_binary is no longer checked against real file existence. A wrong platform subfolder in the allowed mapping would still pass these tests whenever its parent folder is not named common, and the mock applies to every platform test in the suite.
Agent Prompt
## Issue description
The platform selection tests in `py/test/unit/selenium/webdriver/common/selenium_manager_tests.py` monkeypatch `Path.is_file` with `lambda p: p.parent.name != "common"`. This fakes the filesystem based on a folder-name assumption, so the tests no longer verify that `_get_binary` resolves the real binary path for each platform, and they would miss a wrong mapping in the `allowed` dict.
## Fix Focus Areas
- py/test/unit/selenium/webdriver/common/selenium_manager_tests.py[54-54]
- py/test/unit/selenium/webdriver/common/selenium_manager_tests.py[61-61]
- py/selenium/webdriver/common/selenium_manager.py[90-130]
## Recommended Fix
Replace the `is_file` lambda with real file existence: create the expected binary files under a `tmp_path` fixture and point the resolution there, or keep the mock but assert the exact path it was asked about so a wrong mapping still fails.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| SeleniumManager._process_logs(log_items) | ||
| assert "warning message" in caplog.text | ||
| assert "error message" in caplog.text | ||
| assert "info message" in caplog.text | ||
| assert "debug message" in caplog.text |
There was a problem hiding this comment.
2. Error-level test would still pass if logged at wrong level 🐞 Bug ⚙ Maintainability
test_process_logs checks only "error message" in caplog.text, which matches the message at any level, so a regression that routes the ERROR entry to logger.debug or logger.warning would still pass. The test therefore does not verify the new logger.error routing that this PR adds.
Agent Prompt
Issue description
The test `test_process_logs` in py/test/unit/selenium/webdriver/common/selenium_manager_tests.py only checks that each message substring appears in `caplog.text`. This does not confirm that the ERROR entry is emitted at ERROR level, so a regression to a lower level would pass.
Fix Focus Areas
- py/test/unit/selenium/webdriver/common/selenium_manager_tests.py[159-173]
- py/selenium/webdriver/common/selenium_manager.py[166-172]
Recommended Fix
After calling `SeleniumManager._process_logs(log_items)`, assert on `caplog.records`, for example `levels = {r.getMessage(): r.levelno for r in caplog.records}` and check `levels["error message"] == logging.ERROR`, `levels["warning message"] == logging.WARNING`, and the INFO and DEBUG entries map to `logging.DEBUG`.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
@saiyam-jain-dev please check Qodo's comments. |
🔗 Related Issues
💥 What does this PR do?
ERRORlevel logs from Selenium Manager output in_process_logstologger.error(). Previously,_process_logschecked onlyWARN,DEBUG, andINFO, silently discarding entries with levelERROR.py/test/unit/selenium/webdriver/common/selenium_manager_tests.py:_process_logscoveringWARN,ERROR,INFO, andDEBUGlevels.Path.is_filein the platform selection tests (test_uses_windows,test_uses_windows_arm64,test_uses_linux,test_uses_linux_aarch64,test_uses_mac,test_uses_freebsd) so the binary path resolution logic is isolated and does not fail on missing foreign platform binaries in a local development environment.🔧 Implementation Notes
In
_get_binary(),compiled_pathtakes precedence if it exists, otherwise it falls back to the platform specific subfolder inallowed. The unit tests verify the mapping between(sys.platform, platform.machine())and the target binary path. MockingPath.is_fileto only treat non-common paths as present allows testing this mapping cleanly.🤖 AI assistance
🔄 Types of changes