test(shape-render): cover is_hit_by_point and bounds branches - #2368
Merged
Conversation
Owner
Author
Verdict: `recommend-merge` Test-only PR adding coverage for `is_hit_by_point` and `bounds` in `_widgets/_shape_render.py`. Reviewed the diff against source: the tests exercise every branch of `is_hit_by_point` and their assertions match the implementation.
Branch is rebased onto current `main` and CI is green across all 11 configs (lint + 3 OS x Python 3.12/3.13/3.14). No rebase or push needed this tick. Test-only, so no runtime smoke to verify. |
wkentaro
force-pushed
the
test/shape-render-hit-test
branch
from
August 4, 2026 04:56
fa5a27b to
c78c39d
Compare
Add unit tests for the shape hit-test used by canvas selection and hover. is_hit_by_point had no direct unit coverage despite five distinct branches (line/linestrip edge distance, points never-hit, point radius, mask pixel lookup with out-of-bounds guard, and the polygon/rectangle path-containment fallback), exercised only transitively through GUI e2e tests.
wkentaro
force-pushed
the
test/shape-render-hit-test
branch
from
August 4, 2026 06:37
c78c39d to
b135137
Compare
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.
is_hit_by_pointis the shape hit-test that canvas selection and hover depend on, yet it had no direct unit coverage despite five distinct branches (line/linestrip edge distance,pointsnever-hit,pointradius,maskpixel lookup with an out-of-bounds guard, and the polygon/rectangle path-containment fallback) — it was exercised only transitively through GUI e2e canvas tests. This adds focused unit tests for each branch plusbounds().The two tests that reach the
QPainterPathfallback are left unmarked (no@pytest.mark.gui/qapp):QPainterPathis a Qt value type whosecontains()/boundingRect()run with noQApplication, confirmed by running them in isolation.Test plan
uv run pytest tests/unit/widgets/_shape_render_test.py -q— 12 passeduv run ruff check/ruff format --check/uv run ty check— clean