Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testing for drag and drop events/behavior on QtLayerList #6699

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

dalthviz
Copy link
Member

@dalthviz dalthviz commented Mar 1, 2024

References and relevant issues

Closes #1411

Description

Add a test for the layer list drag and drop behavior (use pyautogui and the skip_local_focus decorator):

dragdrop

@github-actions github-actions bot added tests Something related to our tests qt Relates to qt labels Mar 1, 2024
Copy link

codecov bot commented Mar 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.39%. Comparing base (caf6caf) to head (0fa7dc3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6699      +/-   ##
==========================================
- Coverage   92.44%   92.39%   -0.05%     
==========================================
  Files         614      614              
  Lines       54843    54878      +35     
==========================================
+ Hits        50697    50707      +10     
- Misses       4146     4171      +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dalthviz dalthviz self-assigned this Mar 7, 2024
@dalthviz dalthviz marked this pull request as ready for review March 8, 2024 15:29
@dalthviz dalthviz marked this pull request as draft March 8, 2024 15:33
@dalthviz dalthviz marked this pull request as ready for review March 8, 2024 17:06
@psobolewskiPhD psobolewskiPhD added the maintenance PR with maintance changes, label Mar 19, 2024
@psobolewskiPhD psobolewskiPhD added this to the 0.5.0 milestone Mar 19, 2024
@psobolewskiPhD
Copy link
Member

@dalthviz can you clarify, when running locally with NAPARI_FOCUS_TESTS=1 do I need to manually drag the layers (it passes when I do) or should pyautogui be taking care of that?

@dalthviz
Copy link
Member Author

Hi! It should be done automatically (the mouse mouvement and drag&drop action over the widget should be done without you needing to do any manual action) 🤔 If you are checking locally on a machine with macOS, could you give the terminal app Accessibility permissions? You can give it permissions by going to System Settings > Privacy & Security > Accessibility Let me know if that helps!

@psobolewskiPhD
Copy link
Member

That did the trick! Pretty amazing!
I think we'll need to document this somewhere, maybe here:
https://napari.org/stable/developers/testing.html#running-tests

(BTW that seems wrong doesn't it?

There are a very small number of tests (<5) that require showing GUI elements, (such as testing screenshots). By default, these are only run during continuous integration. If you’d like to include them in local tests, set the environment variable “CI”

I know I get windows showing when running locally and it's more than 5... Maybe I'm misunderstanding)

@dalthviz
Copy link
Member Author

That did the trick! Pretty amazing!

Awesome 🎉

I think we'll need to document this somewhere, maybe here:
https://napari.org/stable/developers/testing.html#running-tests

That makes sense and I think I will add a comment over the test docstring to clarify that there too 👍 Also, could make sense to add in the docs the usage of skip_local_focus following the phrasing at https://napari.org/dev/developers/contributing/testing.html#skipping-tests-that-show-gui-elements (either in its own section or as part of that section)?

(BTW that seems wrong doesn't it?

There are a very small number of tests (<5) that require showing GUI elements, (such as testing screenshots). By default, these are only run during continuous integration. If you’d like to include them in local tests, set the environment variable “CI”

I know I get windows showing when running locally and it's more than 5... Maybe I'm misunderstanding)

I think some changes have been done to update that at napari/docs#370 so if you check the page from the dev/latest version of the docs (https://napari.org/dev/developers/contributing/testing.html#running-tests) you see a more up to date phrasing like:

 There are some tests that require showing GUI elements, (such as testing screenshots). By default, these are only run during continuous integration...

Which I think reflects the current test suite state regarding showing GUI elements when running it (indeed more than 5 tests showing GUI elements)

Copy link
Member

@psobolewskiPhD psobolewskiPhD left a comment

Choose a reason for hiding this comment

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

Love it. Makes sense and I checked it locally too -- the new docstring is great, one tiny nitpick/question.
I made a few comments to the partner docs PR -- thanks for taking care of that!

napari/_qt/containers/_tests/test_qt_layer_list.py Outdated Show resolved Hide resolved
Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>
melissawm pushed a commit to napari/docs that referenced this pull request Mar 21, 2024
…sions setup on macOS (#375)

# Description
Add info related with tests that use `pyautogui` and the
`skip_local_focus` decorator like the one being done at
napari/napari#6699

---------

Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>
@psobolewskiPhD psobolewskiPhD added the ready to merge Last chance for comments! Will be merged in ~24h label Apr 4, 2024
@dalthviz dalthviz marked this pull request as draft April 4, 2024 19:13
@Czaki Czaki removed the ready to merge Last chance for comments! Will be merged in ~24h label Apr 4, 2024
@dalthviz
Copy link
Member Author

dalthviz commented Apr 8, 2024

Note: Test fails with PySide6 6.3.1 but passes with PySide6 6.3.2 on Linux when checking locally. Source of segfault seems connected to the wait done with qtbot? 🤔

@psobolewskiPhD
Copy link
Member

But what python version?
as of
#5244
we don't allow 6.3.2 on python 3.10 or above.

@dalthviz
Copy link
Member Author

But what python version?

I was checking with Python 3.10 indeed

as of
#5244
we don't allow 6.3.2 on python 3.10 or above.

Thanks for linking the place where the constraint was done (I was actually unsure why the tests were constrained to that specific PySide6 version on Python 3.9 👍)

@dalthviz dalthviz modified the milestones: 0.5.0, 0.5 Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance PR with maintance changes, qt Relates to qt tests Something related to our tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better Qt tests for mouse move/ drag events
3 participants