test(canvas): cover _is_out_of_image boundary semantics - #2369
Merged
Conversation
Owner
Author
Verdict: recommend-merge Test-only change adding
No CHANGELOG entry (not user-facing). Ready for maintainer to merge. |
wkentaro
force-pushed
the
test/canvas-is-out-of-image
branch
from
August 4, 2026 04:56
d5220fb to
126e1f7
Compare
_is_out_of_image was the sole module-level helper in canvas.py with no direct unit coverage. Pin its inclusive-at-both-edges convention: the top-left and far width/height corners count as inside, while a point just past any edge is out. This is the semantics is_out_of_pixmap relies on to gate vertex/shape clamping.
wkentaro
force-pushed
the
test/canvas-is-out-of-image
branch
from
August 4, 2026 11:29
126e1f7 to
10d2880
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_out_of_imagewas the sole module-level helper incanvas.pywith no directunit coverage — every sibling (
_normalize_bbox_points,_snap_cursor_pos_for_square,etc.) is already imported and tested in
canvas_test.py. It backsis_out_of_pixmap,which gates vertex/shape clamping throughout the drag/move/reproject paths, so its
inclusive-at-both-edges boundary convention is load-bearing.
This pins that convention: the top-left
(0, 0)and far(width, height)cornerscount as inside, an interior point is inside, and a point just past any of the four
edges is out.
Test plan
uv run pytest tests/unit/widgets/canvas_test.py(114 passed)make lint(ruff check,ruff format --check,ty checkall clean)