Try getting selection multiple times
This commit is contained in:
parent
62458c7a84
commit
68af23b76e
@ -49,8 +49,21 @@ class Selection:
|
|||||||
self._callback_checker = utils.CallbackChecker(qtbot)
|
self._callback_checker = utils.CallbackChecker(qtbot)
|
||||||
|
|
||||||
def check(self, expected):
|
def check(self, expected):
|
||||||
self._caret.selection(self._callback_checker.callback)
|
"""Check whether we got the expected selection.
|
||||||
self._callback_checker.check(expected)
|
|
||||||
|
Since (especially on Windows) the selection is empty if we're too
|
||||||
|
quickly, we try to read it multiple times.
|
||||||
|
"""
|
||||||
|
for _ in range(10):
|
||||||
|
with self._qtbot.wait_signal(self._callback_checker.got_result) as blocker:
|
||||||
|
self._caret.selection(self._callback_checker.callback)
|
||||||
|
|
||||||
|
selection = blocker.args[0]
|
||||||
|
if selection:
|
||||||
|
assert selection == expected
|
||||||
|
return
|
||||||
|
|
||||||
|
self._qtbot.wait(50)
|
||||||
|
|
||||||
def check_multiline(self, expected):
|
def check_multiline(self, expected):
|
||||||
self.check(textwrap.dedent(expected).strip())
|
self.check(textwrap.dedent(expected).strip())
|
||||||
|
Loading…
Reference in New Issue
Block a user