test: 100% line coverage + CI coverage gate#238
Open
AkashBrowserStack wants to merge 2 commits into
Open
Conversation
Raise unit coverage from 86% to 100% line coverage with meaningful tests and wire a hard gate into CI so it cannot regress. Tests added: - test_snapshot_units.py (new): targeted unit tests for snapshot.py error and fallback paths the e2e suite doesn't reach — log() shipping failure, _wait_for_ready script-timeout adjust/restore failures, CORS-iframe origin error skip, get_responsive_widths non-list + request failure, CDP resize fallback to set_window_size, _responsive_sleep invalid/unset time, and capture_responsive_dom invalid minHeight handling. - test_init.py (new): percy_screenshot dispatch — unsupported driver, RemoteConnection -> automate, AppiumConnection delegation when the appium package is present, helpful error when it is not, and unknown connection returning None. - robot_library: parse-helper edge cases (_parse_widths/_parse_csv/ _parse_json unsupported types, full _parse_padding matrix), _get_driver SeleniumLibrary-missing error, percy_screenshot keyword (basic + ignore/consider region elements), and a reload-based test of the no-robotframework stub (graceful ImportError). - driver_metadata: command_executor._url -> client_config.remote_server_addr fallback for newer Selenium clients. Instrumentation: - Add .coveragerc (source=percy, fail_under=100, show_missing). - Add coverage to development.txt; new Makefile `coverage` target runs every test module (snapshot under `percy exec --testing`), combines the parallel data, and enforces the threshold. - test.yml runs `make coverage` across the Python matrix. - Add the two new modules to `make test` as well. - __init__: mark two genuinely-unreachable optional-import fallbacks with `# pragma: no cover` (robot_library never raises ImportError; percy.snapshot is the core module and always ships). - gitignore coverage/npm artifacts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the two no-cover pragmas in percy/__init__ with reload-based unit tests that actually execute the fallback lines: - block percy.robot_library so the robot import fails and the except: pass branch runs (package still loads) - inject a percy.snapshot stand-in lacking percy_snapshot so the import fails and the ModuleNotFoundError fallback is defined and raised. Coverage stays at 100% line with no skipped lines. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What & why
This SDK had no coverage enforcement in CI and sat at 86% locally. This PR raises it to 100% line coverage with meaningful tests and wires a hard CI gate so coverage can't silently regress.
Tests added
snapshot.py(newtest_snapshot_units.py)log()CLI-ship failure;_wait_for_readyscript-timeout adjust/restore failures; CORS-iframe origin-error skip;get_responsive_widthsnon-list + request failure; CDP resize →set_window_sizefallback;_responsive_sleepinvalid/unset;capture_responsive_dominvalidminHeightpercy/__init__.py(newtest_init.py)percy_screenshotdispatch (unsupported driver,RemoteConnection→ automate,AppiumConnectiondelegation when appium installed + helpful error when not, unknown →None); and reload-based tests that execute the robot-library and percy_snapshot optional-import fallbacksrobot_library.py_parse_paddingmatrix,_get_drivermissing-SeleniumLibrary error,Percy Screenshotkeyword (+ region elements), reload-based test of the no-robotframework stubdriver_metadata.pyclient_config.remote_server_addrfallbackInstrumentation / gate
.coveragerc—source = percy,fail_under = 100,show_missing.coverage+pytest-covadded todevelopment.txt.make coverageruns every module (snapshot underpercy exec --testing), combines parallel data, and enforces the threshold.test.ymlrunsmake coverageacross the3.8–3.10matrix; new modules also added tomake test.Verification
🤖 Generated with Claude Code