Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify documentation around qtbot.waitSignals #559

Open
gdeane-cri opened this issue Jun 4, 2024 · 1 comment
Open

Clarify documentation around qtbot.waitSignals #559

gdeane-cri opened this issue Jun 4, 2024 · 1 comment

Comments

@gdeane-cri
Copy link

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.

@nicoddemus
Copy link
Member

nicoddemus commented Jun 4, 2024

Or if these are simply an example of how one could assert things on app at that point in the test

Yeah those are meant as examples of that, sorry that is not very clear.

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.

No that Application is not meant to be a QApplication, just as placeholder meaning "your application class" or something like that.

Feel free to open a PR clarifying the docs (or even using a more explicit example if you come up with one), would love to review/merge a PR in that direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants