Description
Problem description
I am having troubles with understanding how to use the functionality qtbot.waitSignal
. I followed the documentation but there must be something I am missing.
It seems that a direct call to the emit
method of a given signal does not trigger a block with qtbot.waitSignal(...
to validate.
I found the problem by testing my application, checking if a button was sending a signal, and noted that the waitSignal
was always hitting the timeout. I extracted what I think is a bug, but might be to my very new discovery of signals and slots.
What I expected / what I get
in a file test_sample.py
:
from PySide.QtCore import QObject, Signal
class Simple(QObject):
signal = Signal()
def test_Qt(qtbot):
simple = Simple()
with qtbot.waitSignal(simple.signal, timeout=1000) as waiting:
simple.signal.emit()
assert waiting.signal_triggered
Running py.test
on this file results in an AssertionError
, because waiting.signal_triggered
is False
. I expected the emit
method to cause waiting
to see the signal being emitted.
Possible things I might do wrong
Since I am new to this signal/slot business, I might be overlooking some essential facts.
- As a zen master would ask, is the signal truly fired if no slot is there to listen to it?
- Could it be that it is that slow to fire a signal?
- Is the
emit
code somehow placed at the wrong spot?
Thank you for enlightening me, and thanks for sharing such a useful work, by the way. Testing GUI applications without this would be a massive pain.
Configuration
I am using Python 2.7.5
, pytest 1.4.24
, and PySide 1.2.2
, on a Linux Mint 16.