8. GUI Testing

A collection of details for creating tests will be collected here. In a later version a guide on how to create test cases will be introduced

8.1. pytest-qt caveats

Some details when dealing with pytest-qt are important.

8.1.1. Timeout on tests but the exact time does not pass, do not call QApplication.quit()

I have run into this once. pytest-qt reported a timeout, but if I increased the timeout in the QtBot.waitForSignal() method, the tests did not take longer, and still, the timeout error was thrown.

After disabling part of the test suite, I realized the error came from executing QApplication.quit() in a previous test. The timeout was generated from the waitForSignal() method, but from pytest-qt communication with its instance of QApplication.

While the test itself did not call QApplication.quit(), it closed the MainWindow, and its closeEvent() method did execute QApplication.quit(). As a general recommendation, don’t call it but instead call the parent (QApplication.closeEvent()) method, so that the normal workflow of qt takes care of this instead. Just handle the resources deallocation and disconnection.