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
Fix flaky dims playback test by waiting for playing condition #5414
Conversation
Codecov Report
@@ Coverage Diff @@
## main #5414 +/- ##
=======================================
Coverage 89.09% 89.09%
=======================================
Files 597 597
Lines 50612 50614 +2
=======================================
+ Hits 45091 45097 +6
+ Misses 5521 5517 -4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@Czaki : I assigned you this because you worked on similar things recently. |
Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Thanks for the review! Will merge this after 24 hours. |
…#5414) Before this change `test_qt_dims.py::test_play_button` tried to wait for `QtDims._animation_thread.started`, which had a few issues. 1. `waitSignal` returns a `SignalBlocker`, but does not actually wait. Based on [the `pytest-qt` docs](https://pytest-qt.readthedocs.io/en/latest/signals.html#) you should typically use that as a context manager to wait, where the code with in the context should eventually cause the signal to be emitted. 2. The intent is to start waiting after mouse click has occurred, but it's possible (though unlikely) that the signal has already been emitted. 3. `QtDims._animation_thread` is `None` before the button has been clicked. This recently caused [a failure on what should be an unrelated PR](https://github.com/napari/napari/actions/runs/3709270881/jobs/6287719643#step:8:379). I don't know enough about `pytest-qt` to confidently explain the failure - but my guess is that the two mouse clicks are being registered as one that starts playback, but does not stop it. The fix here is to use `waitUntil` to wait on `QtDims.is_playing` instead. This makes the test slightly less inefficient, but also makes it simpler and less dependent on implementation details. I also removed a couple of timeout values because the default is 5000 (milliseconds) anyway - if waiting 5 seconds didn't work, waiting another 2 seconds is almost always just wishful thinking. Finally, I removed some other leftovers from napari#5373
Assigned the 0.4.18 milestone because although this is mostly about tests and shouldn't matter, it also removes an unnecessary |
Before this change `test_qt_dims.py::test_play_button` tried to wait for `QtDims._animation_thread.started`, which had a few issues. 1. `waitSignal` returns a `SignalBlocker`, but does not actually wait. Based on [the `pytest-qt` docs](https://pytest-qt.readthedocs.io/en/latest/signals.html#) you should typically use that as a context manager to wait, where the code with in the context should eventually cause the signal to be emitted. 2. The intent is to start waiting after mouse click has occurred, but it's possible (though unlikely) that the signal has already been emitted. 3. `QtDims._animation_thread` is `None` before the button has been clicked. This recently caused [a failure on what should be an unrelated PR](https://github.com/napari/napari/actions/runs/3709270881/jobs/6287719643#step:8:379). I don't know enough about `pytest-qt` to confidently explain the failure - but my guess is that the two mouse clicks are being registered as one that starts playback, but does not stop it. The fix here is to use `waitUntil` to wait on `QtDims.is_playing` instead. This makes the test slightly less inefficient, but also makes it simpler and less dependent on implementation details. I also removed a couple of timeout values because the default is 5000 (milliseconds) anyway - if waiting 5 seconds didn't work, waiting another 2 seconds is almost always just wishful thinking. Finally, I removed some other leftovers from #5373
Before this change `test_qt_dims.py::test_play_button` tried to wait for `QtDims._animation_thread.started`, which had a few issues. 1. `waitSignal` returns a `SignalBlocker`, but does not actually wait. Based on [the `pytest-qt` docs](https://pytest-qt.readthedocs.io/en/latest/signals.html#) you should typically use that as a context manager to wait, where the code with in the context should eventually cause the signal to be emitted. 2. The intent is to start waiting after mouse click has occurred, but it's possible (though unlikely) that the signal has already been emitted. 3. `QtDims._animation_thread` is `None` before the button has been clicked. This recently caused [a failure on what should be an unrelated PR](https://github.com/napari/napari/actions/runs/3709270881/jobs/6287719643#step:8:379). I don't know enough about `pytest-qt` to confidently explain the failure - but my guess is that the two mouse clicks are being registered as one that starts playback, but does not stop it. The fix here is to use `waitUntil` to wait on `QtDims.is_playing` instead. This makes the test slightly less inefficient, but also makes it simpler and less dependent on implementation details. I also removed a couple of timeout values because the default is 5000 (milliseconds) anyway - if waiting 5 seconds didn't work, waiting another 2 seconds is almost always just wishful thinking. Finally, I removed some other leftovers from #5373
Before this change `test_qt_dims.py::test_play_button` tried to wait for `QtDims._animation_thread.started`, which had a few issues. 1. `waitSignal` returns a `SignalBlocker`, but does not actually wait. Based on [the `pytest-qt` docs](https://pytest-qt.readthedocs.io/en/latest/signals.html#) you should typically use that as a context manager to wait, where the code with in the context should eventually cause the signal to be emitted. 2. The intent is to start waiting after mouse click has occurred, but it's possible (though unlikely) that the signal has already been emitted. 3. `QtDims._animation_thread` is `None` before the button has been clicked. This recently caused [a failure on what should be an unrelated PR](https://github.com/napari/napari/actions/runs/3709270881/jobs/6287719643#step:8:379). I don't know enough about `pytest-qt` to confidently explain the failure - but my guess is that the two mouse clicks are being registered as one that starts playback, but does not stop it. The fix here is to use `waitUntil` to wait on `QtDims.is_playing` instead. This makes the test slightly less inefficient, but also makes it simpler and less dependent on implementation details. I also removed a couple of timeout values because the default is 5000 (milliseconds) anyway - if waiting 5 seconds didn't work, waiting another 2 seconds is almost always just wishful thinking. Finally, I removed some other leftovers from #5373
Before this change `test_qt_dims.py::test_play_button` tried to wait for `QtDims._animation_thread.started`, which had a few issues. 1. `waitSignal` returns a `SignalBlocker`, but does not actually wait. Based on [the `pytest-qt` docs](https://pytest-qt.readthedocs.io/en/latest/signals.html#) you should typically use that as a context manager to wait, where the code with in the context should eventually cause the signal to be emitted. 2. The intent is to start waiting after mouse click has occurred, but it's possible (though unlikely) that the signal has already been emitted. 3. `QtDims._animation_thread` is `None` before the button has been clicked. This recently caused [a failure on what should be an unrelated PR](https://github.com/napari/napari/actions/runs/3709270881/jobs/6287719643#step:8:379). I don't know enough about `pytest-qt` to confidently explain the failure - but my guess is that the two mouse clicks are being registered as one that starts playback, but does not stop it. The fix here is to use `waitUntil` to wait on `QtDims.is_playing` instead. This makes the test slightly less inefficient, but also makes it simpler and less dependent on implementation details. I also removed a couple of timeout values because the default is 5000 (milliseconds) anyway - if waiting 5 seconds didn't work, waiting another 2 seconds is almost always just wishful thinking. Finally, I removed some other leftovers from #5373
Before this change `test_qt_dims.py::test_play_button` tried to wait for `QtDims._animation_thread.started`, which had a few issues. 1. `waitSignal` returns a `SignalBlocker`, but does not actually wait. Based on [the `pytest-qt` docs](https://pytest-qt.readthedocs.io/en/latest/signals.html#) you should typically use that as a context manager to wait, where the code with in the context should eventually cause the signal to be emitted. 2. The intent is to start waiting after mouse click has occurred, but it's possible (though unlikely) that the signal has already been emitted. 3. `QtDims._animation_thread` is `None` before the button has been clicked. This recently caused [a failure on what should be an unrelated PR](https://github.com/napari/napari/actions/runs/3709270881/jobs/6287719643#step:8:379). I don't know enough about `pytest-qt` to confidently explain the failure - but my guess is that the two mouse clicks are being registered as one that starts playback, but does not stop it. The fix here is to use `waitUntil` to wait on `QtDims.is_playing` instead. This makes the test slightly less inefficient, but also makes it simpler and less dependent on implementation details. I also removed a couple of timeout values because the default is 5000 (milliseconds) anyway - if waiting 5 seconds didn't work, waiting another 2 seconds is almost always just wishful thinking. Finally, I removed some other leftovers from #5373
Before this change `test_qt_dims.py::test_play_button` tried to wait for `QtDims._animation_thread.started`, which had a few issues. 1. `waitSignal` returns a `SignalBlocker`, but does not actually wait. Based on [the `pytest-qt` docs](https://pytest-qt.readthedocs.io/en/latest/signals.html#) you should typically use that as a context manager to wait, where the code with in the context should eventually cause the signal to be emitted. 2. The intent is to start waiting after mouse click has occurred, but it's possible (though unlikely) that the signal has already been emitted. 3. `QtDims._animation_thread` is `None` before the button has been clicked. This recently caused [a failure on what should be an unrelated PR](https://github.com/napari/napari/actions/runs/3709270881/jobs/6287719643#step:8:379). I don't know enough about `pytest-qt` to confidently explain the failure - but my guess is that the two mouse clicks are being registered as one that starts playback, but does not stop it. The fix here is to use `waitUntil` to wait on `QtDims.is_playing` instead. This makes the test slightly less inefficient, but also makes it simpler and less dependent on implementation details. I also removed a couple of timeout values because the default is 5000 (milliseconds) anyway - if waiting 5 seconds didn't work, waiting another 2 seconds is almost always just wishful thinking. Finally, I removed some other leftovers from #5373
Before this change `test_qt_dims.py::test_play_button` tried to wait for `QtDims._animation_thread.started`, which had a few issues. 1. `waitSignal` returns a `SignalBlocker`, but does not actually wait. Based on [the `pytest-qt` docs](https://pytest-qt.readthedocs.io/en/latest/signals.html#) you should typically use that as a context manager to wait, where the code with in the context should eventually cause the signal to be emitted. 2. The intent is to start waiting after mouse click has occurred, but it's possible (though unlikely) that the signal has already been emitted. 3. `QtDims._animation_thread` is `None` before the button has been clicked. This recently caused [a failure on what should be an unrelated PR](https://github.com/napari/napari/actions/runs/3709270881/jobs/6287719643#step:8:379). I don't know enough about `pytest-qt` to confidently explain the failure - but my guess is that the two mouse clicks are being registered as one that starts playback, but does not stop it. The fix here is to use `waitUntil` to wait on `QtDims.is_playing` instead. This makes the test slightly less inefficient, but also makes it simpler and less dependent on implementation details. I also removed a couple of timeout values because the default is 5000 (milliseconds) anyway - if waiting 5 seconds didn't work, waiting another 2 seconds is almost always just wishful thinking. Finally, I removed some other leftovers from #5373
Description
Before this change
test_qt_dims.py::test_play_button
tried to wait forQtDims._animation_thread.started
, which had a few issues.waitSignal
returns aSignalBlocker
, but does not actually wait. Based on thepytest-qt
docs you should typically use that as a context manager to wait, where the code with in the context should eventually cause the signal to be emitted.QtDims._animation_thread
isNone
before the button has been clicked.This recently caused a failure on what should be an unrelated PR. I don't know enough about
pytest-qt
to confidently explain the failure - but my guess is that the two mouse clicks are being registered as one that starts playback, but does not stop it.The fix here is to use
waitUntil
to wait onQtDims.is_playing
instead. This makes the test slightly less inefficient, but also makes it simpler and less dependent on implementation details.I also removed a couple of timeout values because the default is 5000 (milliseconds) anyway - if waiting 5 seconds didn't work, waiting another 2 seconds is almost always just wishful thinking.
Finally, I removed some other leftovers from #5373
Type of change