@@ -161,15 +161,6 @@ class QtBot(object):
161
161
162
162
"""
163
163
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
-
173
164
def __init__ (self ):
174
165
self ._widgets = [] # list of weakref to QWidget instances
175
166
@@ -272,8 +263,8 @@ def waitSignal(self, signal=None, timeout=1000, raising=False):
272
263
:param int timeout:
273
264
How many milliseconds to wait before resuming control flow.
274
265
: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 .
277
268
:returns:
278
269
``SignalBlocker`` object. Call ``SignalBlocker.wait()`` to wait.
279
270
@@ -305,7 +296,7 @@ class SignalBlocker(object):
305
296
this is set to ``None``.
306
297
307
298
: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 .
309
300
"""
310
301
311
302
def __init__ (self , timeout = 1000 , raising = False ):
@@ -330,13 +321,16 @@ def wait(self):
330
321
QtCore .QTimer .singleShot (self .timeout , self ._loop .quit )
331
322
self ._loop .exec_ ()
332
323
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." %
334
325
self .timeout )
335
326
336
327
def connect (self , signal ):
337
328
"""
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.
340
334
341
335
:param signal: QtCore.Signal
342
336
"""
@@ -357,6 +351,19 @@ def __exit__(self, type, value, traceback):
357
351
self .wait ()
358
352
359
353
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
+
360
367
@contextmanager
361
368
def capture_exceptions ():
362
369
"""
0 commit comments