Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attempt to fix an intermittent failure in GUI tests (#625)
Move to using pyqt's qtbot fixture instead of a hand-rolled wait function
- Loading branch information
Showing
2 changed files
with
36 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,3 @@ | ||
from contextlib import contextmanager | ||
|
||
from PySide2.QtCore import QEventLoop, QTimer | ||
from PySide2.QtWidgets import QApplication | ||
|
||
APP = QApplication([]) # we need an application to create widgets | ||
|
||
|
||
@contextmanager | ||
def wait_signal(signal, timeout=5): | ||
"""Block loop until signal emitted, or timeout (s) elapses.""" | ||
loop = QEventLoop() | ||
signal.connect(loop.quit) | ||
|
||
yield | ||
|
||
timed_out = [] | ||
if timeout is not None: | ||
|
||
def quit_with_error(): | ||
timed_out.append(1) | ||
loop.quit() | ||
|
||
QTimer.singleShot(timeout * 1000, quit_with_error) | ||
loop.exec_() | ||
if timed_out: | ||
assert False, "Timeout while waiting for %s" % signal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters