Skip to content

Commit 35cb7a1

Browse files
committed
SignalTimeoutError no longer nested and small docs adjustments
- SignalTimeoutError is a top level class because Sphinx doesn't like nested classes. Still kept a reference to it in QtBot for easy access from qtbot fixtures - Few minor doc tweaks
1 parent ce08eae commit 35cb7a1

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

pytestqt/plugin.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,6 @@ class QtBot(object):
161161
162162
"""
163163

164-
class SignalTimeout(Exception):
165-
"""
166-
.. versionadded:: 1.4
167-
168-
The exception thrown by :meth:`QtBot.waitSignal` if the *raising*
169-
parameter has been given and there was a timeout.
170-
"""
171-
pass
172-
173164
def __init__(self):
174165
self._widgets = [] # list of weakref to QWidget instances
175166

@@ -272,8 +263,8 @@ def waitSignal(self, signal=None, timeout=1000, raising=False):
272263
:param int timeout:
273264
How many milliseconds to wait before resuming control flow.
274265
:param bool raising:
275-
If :class:`QtBot.TimeoutError` should be raised if a timeout
276-
occured.
266+
If :class:`QtBot.SignalTimeoutError <pytestqt.plugin.SignalTimeoutError>`
267+
should be raised if a timeout occurred.
277268
:returns:
278269
``SignalBlocker`` object. Call ``SignalBlocker.wait()`` to wait.
279270
@@ -305,7 +296,7 @@ class SignalBlocker(object):
305296
this is set to ``None``.
306297
307298
:ivar bool raising:
308-
If :class:`QtBot.TimeoutError` should be raised if a timeout occured.
299+
If :class:`SignalTimeoutError` should be raised if a timeout occurred.
309300
"""
310301

311302
def __init__(self, timeout=1000, raising=False):
@@ -330,13 +321,16 @@ def wait(self):
330321
QtCore.QTimer.singleShot(self.timeout, self._loop.quit)
331322
self._loop.exec_()
332323
if not self.signal_triggered and self.raising:
333-
raise QtBot.SignalTimeout("Didn't get signal after %sms." %
324+
raise SignalTimeoutError("Didn't get signal after %sms." %
334325
self.timeout)
335326

336327
def connect(self, signal):
337328
"""
338-
Connects to the given signal, making :meth:`wait()` return once this signal
339-
is emitted.
329+
Connects to the given signal, making :meth:`wait()` return once
330+
this signal is emitted.
331+
332+
More than one signal can be connected, in which case **any** one of
333+
them will make ``wait()`` return.
340334
341335
:param signal: QtCore.Signal
342336
"""
@@ -357,6 +351,19 @@ def __exit__(self, type, value, traceback):
357351
self.wait()
358352

359353

354+
class SignalTimeoutError(Exception):
355+
"""
356+
.. versionadded:: 1.4
357+
358+
The exception thrown by :meth:`QtBot.waitSignal` if the *raising*
359+
parameter has been given and there was a timeout.
360+
"""
361+
pass
362+
363+
# provide easy access to SignalTimeoutError to qtbot fixtures
364+
QtBot.SignalTimeoutError = SignalTimeoutError
365+
366+
360367
@contextmanager
361368
def capture_exceptions():
362369
"""

0 commit comments

Comments
 (0)