Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Trigger events via standard callbacks in widget testing.#29993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
anntzer wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromanntzer:undoevent

Conversation

anntzer
Copy link
Contributor

Sending actual events through the whole event processing pipeline is a more complete test, reveals a few minor issues (see changes below), and avoids being linked to the rather nonstandard widget method names ("press" or "_click"?).

The coordinates in the "move first vertex after completing the polygon" subtest of test_polygon_selector(draw_bounding_box=True) were altered because the original coordinates would actually not work in a real case, as the mouse-drag would actually also trigger the polygon-rescaling behavior.

The coordinates in test_rectangle_{drag,resize} were altered because for the original coordinates, the click_and_drag would actually be ignore()d due to starting (just) outside of the axes.

Closes#22720.

PR summary

PR checklist

Sending actual events through the whole event processing pipeline is amore complete test, reveals a few minor issues (see changes below), andavoids being linked to the rather nonstandard widget method names("press" or "_click"?).The coordinates in the "move first vertex after completing the polygon"subtest of test_polygon_selector(draw_bounding_box=True) were alteredbecause the original coordinates would actually not work in a real case,as the mouse-drag would actually also trigger the polygon-rescalingbehavior.The coordinates in test_rectangle_{drag,resize} were altered because forthe original coordinates, the click_and_drag would actually be ignore()ddue to starting (just) outside of the axes.
@@ -137,7 +135,7 @@ def test_rectangle_drag(ax, drag_from_anywhere, new_center):
tool = widgets.RectangleSelector(ax, interactive=True,
drag_from_anywhere=drag_from_anywhere)
# Create rectangle
click_and_drag(tool, start=(0, 10), end=(100, 120))
click_and_drag(tool, start=(10, 10), end=(90, 120))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The positions in the last part of this test are also outside both before and after rectangles, so just checking if those are still valid, or are they actually outside theAxes just as these were (and thus not checking what was intended)?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The axes default to ranging from 0 to 200, so the last part's rectangles are within the axes.

@dstansby
Copy link
Member

👍 to removingdo_event() from the public API, but it is a useful helper for testing. Why not keep it around (rename to_do_event()), and change the function definition toMouseEvent._from_ax_coords(...)._process()? That way it would avoid having to remember to have to call_from_ax_coords()and_process() across the tests.

@anntzer
Copy link
ContributorAuthor

The problem is that right now do_event takes a (not-standardized) widget method name as parameter. I guess, sure, we could completely change the signature and have a privatedo_event("button_press_event", ax, xycoords, button) helper method, but if we really think thatMouseEvent._from_ax_coords(...)._process() is not ergonomic enough, perhaps that rather points to the fact that that API should be reworked anyways (which is not something I really want to go into right now)?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@QuLogicQuLogicQuLogic left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[MNT]: Generalize widget mouse testing
3 participants
@anntzer@dstansby@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp