Python

Testing PySide/PyQt Code Easily Using the Pytest Framework


A03 6.11.2019 16:30 - 17:00

Bookmark and Share

Florian Bruhin
Florian Bruhin
Bruhin Software

Both PySide and PyQt allow rapid prototyping and development of Qt applications using the Python programming language. However, the Qt Test framework is focused on C++, and only a subset of its functionality is available in Python. Together with the “unittest” module in the Python standard library (which exposes a heavyweight, xUnit-like API), this can make tests unnecessarily cumbersome to write. The pytest framework coupled with the pytest-qt plugin allows writing tests for Qt/Python code in a much more straightforward and fun way. It exposes the QTestLib API, but also adds various high-level functionality with an API which is more suitable for Python code. This talk will give the audience a short introduction to pytest and explain how to test Python/Qt code using the pytest-qt plugin. It will also take a quick look at other useful pytest plugins which can be combined with pytest-qt.