nicoddemus/pytest-qt — pull request #14 by jdreaver (2014-07-02 23:32:41+00:00)
Title: Wait signal

I like the changes to SignalBlocker. That is a great, simple way to check if the signal was called.

One note about the context manager: the point of the context manager is to connect the signal(s) *before* some operation that fires signals begins. For example, if we call `worker.run()` before connecting the signals, there is a race condition; the signals might fire before the loop is executed, and we will have to use the timeout.

Also, the example doesn't look correct. The `assert blocker.signal_triggered` will fail because ``wait()`` is not called until the `with` statement exits. I would change the example in the docs to this:

```python
def test_long_computation(qtbot):
app = Application()

# Watch for the app.worker.finished signal, then start the worker.
with qtbot.waitSignal(app.worker.finished, timeout=10000) as blocker:
blocker.connect(app.worker.failed) # Can add other signals to blocker
app.worker.start()

# Test will wait here until either signal is emitted, or 10 seconds has elapsed

assert blocker.signal_triggered # Assuming the work took less than 10 seconds
assert_application_results(app)
```

Other than changing the example, I think the explanation in the docs is great, and your refactoring of the tests and code looks awesome!