@@ -252,10 +252,12 @@ def waitSignal(self, signal=None, timeout=1000, raising=False):
252
252
manager form is not convenient::
253
253
254
254
blocker = qtbot.waitSignal(signal, timeout=1000)
255
- blocker.connect(other_signal )
255
+ blocker.connect(another_signal )
256
256
long_function_that_calls_signal()
257
257
blocker.wait()
258
258
259
+ Any additional signal, when triggered, will make :meth:`wait` return.
260
+
259
261
.. versionadded:: 1.4
260
262
The *raising* parameter.
261
263
@@ -286,20 +288,19 @@ def waitSignals(self, signals=None, timeout=1000, raising=False):
286
288
287
289
Stops current test until all given signals are triggered.
288
290
289
- Used to stop the control flow of a test until all given signals are
290
- emitted, or a number of milliseconds, specified by ``timeout``, has
291
- elapsed.
291
+ Used to stop the control flow of a test until all (and only
292
+ all) signals are emitted, or a number of milliseconds, specified by
293
+ ``timeout``, has elapsed.
292
294
293
295
Best used as a context manager::
294
296
295
- with qtbot.waitSignals(signal , timeout=1000):
296
- long_function_that_calls_signal ()
297
+ with qtbot.waitSignals([signal1, signal2] , timeout=1000):
298
+ long_function_that_calls_signals ()
297
299
298
300
Also, you can use the :class:`MultiSignalBlocker` directly if the
299
301
context manager form is not convenient::
300
302
301
- blocker = qtbot.waitSignals(signal, timeout=1000)
302
- blocker.connect(other_signal)
303
+ blocker = qtbot.waitSignals(signals, timeout=1000)
303
304
long_function_that_calls_signal()
304
305
blocker.wait()
305
306
@@ -322,13 +323,13 @@ def waitSignals(self, signals=None, timeout=1000, raising=False):
322
323
blocker = MultiSignalBlocker (timeout = timeout , raising = raising )
323
324
if signals is not None :
324
325
for signal in signals :
325
- blocker .add_signal (signal )
326
+ blocker ._add_signal (signal )
326
327
return blocker
327
328
328
329
wait_signals = waitSignals # pep-8 alias
329
330
330
331
331
- class AbstractSignalBlocker (object ):
332
+ class _AbstractSignalBlocker (object ):
332
333
333
334
"""
334
335
Base class for :class:`SignalBlocker` and :class:`MultiSignalBlocker`.
@@ -340,16 +341,6 @@ class AbstractSignalBlocker(object):
340
341
Subclasses also need to provide ``self._signals`` which should evaluate to
341
342
``False`` if no signals were configured.
342
343
343
- :ivar int timeout: maximum time to wait for a signal to be triggered. Can
344
- be changed before :meth:`wait` is called.
345
-
346
- :ivar bool signal_triggered: set to ``True`` if a signal (or all signals in
347
- case of :class:MultipleSignalBlocker:) was triggered, or
348
- ``False`` if timeout was reached instead. Until :meth:`wait` is called,
349
- this is set to ``None``.
350
-
351
- :ivar bool raising:
352
- If :class:`SignalTimeoutError` should be raised if a timeout occurred.
353
344
"""
354
345
355
346
def __init__ (self , timeout = 1000 , raising = False ):
@@ -383,14 +374,24 @@ def __exit__(self, type, value, traceback):
383
374
self .wait ()
384
375
385
376
386
- class SignalBlocker (AbstractSignalBlocker ):
377
+ class SignalBlocker (_AbstractSignalBlocker ):
387
378
388
379
"""
389
380
Returned by :meth:`QtBot.waitSignal` method.
390
381
382
+ :ivar int timeout: maximum time to wait for a signal to be triggered. Can
383
+ be changed before :meth:`wait` is called.
384
+
385
+ :ivar bool signal_triggered: set to ``True`` if a signal (or all signals in
386
+ case of :class:`MultipleSignalBlocker`) was triggered, or
387
+ ``False`` if timeout was reached instead. Until :meth:`wait` is called,
388
+ this is set to ``None``.
389
+
390
+ :ivar bool raising:
391
+ If :class:`SignalTimeoutError` should be raised if a timeout occurred.
392
+
391
393
.. automethod:: wait
392
394
.. automethod:: connect
393
-
394
395
"""
395
396
396
397
def __init__ (self , timeout = 1000 , raising = False ):
@@ -418,20 +419,25 @@ def _quit_loop_by_signal(self):
418
419
self ._loop .quit ()
419
420
420
421
421
- class MultiSignalBlocker (AbstractSignalBlocker ):
422
+ class MultiSignalBlocker (_AbstractSignalBlocker ):
422
423
423
424
"""
424
- Returned by :meth:`QtBot.waitSignals` method.
425
+ Returned by :meth:`QtBot.waitSignals` method, blocks until all signals
426
+ connected to it are triggered or the timeout is reached.
427
+
428
+ Variables identical to :class:`SignalBlocker`:
429
+ - ``timeout``
430
+ - ``signal_triggered``
431
+ - ``raising``
425
432
426
433
.. automethod:: wait
427
- .. automethod:: add_signal
428
434
"""
429
435
430
436
def __init__ (self , timeout = 1000 , raising = False ):
431
437
super (MultiSignalBlocker , self ).__init__ (timeout , raising = raising )
432
438
self ._signals = {}
433
439
434
- def add_signal (self , signal ):
440
+ def _add_signal (self , signal ):
435
441
"""
436
442
Adds the given signal to the list of signals which :meth:`wait()` waits
437
443
for.
0 commit comments