test: 100% line coverage + CI coverage gate#238
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>
Claude Code PR ReviewPR: #238 • Head: 083ef0e • Reviewers: stack:code-reviewer SummaryAdds focused unit tests for the package entrypoint, Review Table
FindingsNo Critical or High findings. Minor (Low) observations, non-blocking:
Verdict: PASS — tests are faithful to the real code paths, all 53 pass locally, and the coverage gate tooling is internally consistent. |
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