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

Don't do unnecessary condition evaluations in assertEventuallyTrueInGui #1168

Merged

Conversation

mdickinson
Copy link
Member

@mdickinson mdickinson commented Nov 7, 2022

GuiTestAssistant.assertEventuallyTrueInGui does an unnecessary extra condition evaluation after the event loop has exited. In the worst case, when the condition is only valid during a running event loop, this can cause spurious test failures.

This PR updates the code so that it doesn't re-evaluate the condition once the condition has evaluated to True for the first time.

Design note: the bool() call is in there to avoid hanging onto references in case the user-supplied condition returns something more complicated that a simple bool.


EDIT: I've also updated the PR to use the exit method instead of the quit method within event_loop_until_condition; all we want here is to exit the event loop that was started using self.qt_app.exec_ - not to tear down anything else.

@mdickinson
Copy link
Member Author

CI is failing for unrelated reasons. I suggest that we pin our PySide6 version in CI in the short term.

@mdickinson
Copy link
Member Author

#1169 should fix the unrelated CI failures, so that we can see whether there are any related failures.

@mdickinson
Copy link
Member Author

Looks like this makes some existing macOS tests unhappy. Investigating.

@mdickinson mdickinson marked this pull request as draft November 7, 2022 17:38
@mdickinson
Copy link
Member Author

Marking as draft, since there seem to be some unexpected interactions with the ModalDialogTester: see #1170.

@corranwebster
Copy link
Contributor

The failures for the font and color dialogs seem to be happening in the tests for the utility functions get_color and get_font which wrap the dialogs, rather than the main tests for the dialogs themselves.

Possibly there is an issue with needed objects being gc'd or not cleaned up correctly?

@corranwebster
Copy link
Contributor

This should resolve #1170 as well.

Copy link
Contributor

@corranwebster corranwebster left a comment

Choose a reason for hiding this comment

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

Looks good.

@mdickinson mdickinson marked this pull request as ready for review November 9, 2022 09:36
@mdickinson
Copy link
Member Author

Thanks, @corranwebster. I'm happy for this to be merged if you are.

@corranwebster corranwebster merged commit c5f57ca into main Nov 9, 2022
@corranwebster corranwebster deleted the fix/spurious-condition-evaluations-in-gui-test-assistant branch November 9, 2022 09:39
@corranwebster corranwebster added the needs backport to maint/* This issue needs to be backported to a maintenance branch label Nov 9, 2022
corranwebster added a commit that referenced this pull request Nov 11, 2022
…ui (#1168)

`GuiTestAssistant.assertEventuallyTrueInGui` does an unnecessary extra `condition` evaluation after the event loop has exited. In the worst case, when the condition is only valid during a running event loop, this can cause spurious test failures.

This PR updates the code so that it doesn't re-evaluate the condition once the condition has evaluated to `True` for the first time.

Design note: the `bool()` call is in there to avoid hanging onto references in case the user-supplied condition returns something more complicated that a simple bool.

---

EDIT: I've also updated the PR to use the `exit` method instead of the `quit` method within `event_loop_until_condition`; all we want here is to exit the event loop that was started using `self.qt_app.exec_` - not to tear down anything else.

Co-authored-by: Corran Webster <cwebster@enthought.com>
corranwebster added a commit that referenced this pull request Nov 14, 2022
…ui (#1168)

`GuiTestAssistant.assertEventuallyTrueInGui` does an unnecessary extra `condition` evaluation after the event loop has exited. In the worst case, when the condition is only valid during a running event loop, this can cause spurious test failures.

This PR updates the code so that it doesn't re-evaluate the condition once the condition has evaluated to `True` for the first time.

Design note: the `bool()` call is in there to avoid hanging onto references in case the user-supplied condition returns something more complicated that a simple bool.

---

EDIT: I've also updated the PR to use the `exit` method instead of the `quit` method within `event_loop_until_condition`; all we want here is to exit the event loop that was started using `self.qt_app.exec_` - not to tear down anything else.

Co-authored-by: Corran Webster <cwebster@enthought.com>
@corranwebster corranwebster restored the fix/spurious-condition-evaluations-in-gui-test-assistant branch November 17, 2022 12:24
@corranwebster corranwebster deleted the fix/spurious-condition-evaluations-in-gui-test-assistant branch November 17, 2022 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs backport to maint/* This issue needs to be backported to a maintenance branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants