Georgy Ivanov
Georgy Ivanov

Reputation: 686

How can can I run tests using qtbot on macos Sonoma?

After upgrade to MacOS Sonoma, even simple tests like

def test_repro(qtbot):
    pass

hang indefinitely.

The related github issue has been closed, without any suggested workarounds.

Can someone perhaps come up with any workarounds here?

Upvotes: 1

Views: 109

Answers (1)

Georgy Ivanov
Georgy Ivanov

Reputation: 686

While there's an ongoing discussion on the github issue, and the new App Activation API is pointed out as a suspected culprit, what worked for me was to replace

def _process_events():
    """Calls app.processEvents() while taking care of capturing exceptions
    or not based on the given item's configuration.
    """
    app = qt_api.QtWidgets.QApplication.instance()
    if app is not None:
        app.processEvents()

with

def _process_events():
    """Calls app.processEvents() while taking care of capturing exceptions
    or not based on the given item's configuration.
    """
    app = qt_api.QtWidgets.QApplication.instance()
    if app is not None:
        # app.processEvents()
        pass

in pytestqt/plugin.py.

In my case, I was able to edit it from PyCharm, it was under "External libraries -> Python 3.11 -> site-packages -> pytestqt -> plugin.py".

Not sure if it broke some other important functionality in qtbot, but at least my tests began to pass, and unblocked me in the short run.

Upvotes: 2

Related Questions