Skip to content

Clarify documentation around qtbot.waitSignals #559

@gdeane-cri

Description

@gdeane-cri

The current docs (https://pytest-qt.readthedocs.io/en/1.5.0/signals.html ) give some examples like this:

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 block at this point until signal is emitted or
        # 10 seconds has elapsed

    assert blocker.signal_triggered, "process timed-out"
    assert_application_results(app)

Except this does not work for me because Application() and assert_application_results are not defined. But the example reads as if this is a necessary step to verify the signal result. Is there some import required for these to function? Are they obsolete? Or if these are simply an example of how one could assert things on app at that point in the test, consider clarifying the example as written.

How to get the QApplication instance when using qtbot is a bit mysterious in the docs too. It just says you can.
Application appears to be replaceable using from pytestqt.qt_compat import qt_api; Application = qt_api.QtWidgets.QApplication.instance but I have no idea if this is good practice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions