You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The wait_until_signal function has the limitation that it starts listening for a signal only after the code that should emit that signal was called. This means there is a time window in between these calls in which the signal could be emitted but is not seen by the wait. I.e. a race condition.
The wait_signal context manager from pytest-qt does not have this issue because it wraps the code that is expected to emit the given signal in a with block and therefore starts listening before the signal has a chance to be emitted.
The text was updated successfully, but these errors were encountered:
@matrss correct me if i am wrong, according Recommended approach i need to replace wait_until_signal function with qtbot.wait_signal within with blocks.
so for that i need make changes in this this files:-
by replacing with this for example:
with qtbot.wait_signal(self.wms_control.cpdig.canceled):
# I'll adjust the signal names (cpdig.canceled, image_displayed, etc.) to match the actual signals
while doing this ill be importing qtbot like this: from pytestqt.qtbot import qtbot
But, what do i do with the function wait_until_signal in utils.pyshould i remove it since we'll be using qtbot.wait_signal insted.
or is their anything more that should be done to solve this issue ? just wanted to confirm before making the changes.
@matrss correct me if i am wrong, according Recommended approach i need to replace wait_until_signal function with qtbot.wait_signal within with blocks. so for that i need make changes in this this files:- by replacing with this for example:
with qtbot.wait_signal(self.wms_control.cpdig.canceled):
# I'll adjust the signal names (cpdig.canceled, image_displayed, etc.) to match the actual signals
Yes, exactly.
while doing this ill be importing qtbot like this: from pytestqt.qtbot import qtbot
No, qtbot is a pytest fixture (https://docs.pytest.org/en/stable/how-to/fixtures.html#how-to-fixtures). That means it just needs to be added as a function argument to the test function, if it isn't there already. You can grep for qtbot in tests/ to see how it is used in other places.
But, what do i do with the function wait_until_signal in utils.pyshould i remove it since we'll be using qtbot.wait_signal insted.
When it is no longer used anywhere it can be removed.
or is their anything more that should be done to solve this issue ? just wanted to confirm before making the changes.
The
wait_until_signal
function has the limitation that it starts listening for a signal only after the code that should emit that signal was called. This means there is a time window in between these calls in which the signal could be emitted but is not seen by the wait. I.e. a race condition.The
wait_signal
context manager from pytest-qt does not have this issue because it wraps the code that is expected to emit the given signal in awith
block and therefore starts listening before the signal has a chance to be emitted.The text was updated successfully, but these errors were encountered: