Skip to content

waitSignal support added

Compare
Choose a tag to compare
@nicoddemus nicoddemus released this 03 Jul 00:53
· 1004 commits to master since this release

This version include the new waitSignal function, which makes it easy to write tests for long running computations that happen in other threads or processes:

    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)

Many thanks to @jdreaver for discussion and complete PR! (#12, #13)