August 2018
Beginner
160 pages
4h 8m
English
The pytest-qt plugin allows you to write tests for GUI applications written in the Qt framework (https://www.qt.io/), supporting the more popular sets of Python bindings for Qt: PyQt4/PyQt5, and PySide/PySide2.
It provides a qtbot fixture that has methods to interact with a GUI application, such as clicking on buttons, entering text in fields, waiting for windows to pop up, and others. Here's a quick example showing it in action:
def test_main_window(qtbot): widget = MainWindow() qtbot.addWidget(widget) qtbot.mouseClick(widget.about_button, QtCore.Qt.LeftButton) qtbot.waitUntil(widget.about_box.isVisible) assert widget.about_box.text() == 'This is a GUI App'
Here, we create a window, click on the about button, wait for the about ...
Read now
Unlock full access