pytest-qt
pytest support for PyQt and PySide applications
Decision gist · record as of 2026-08-14
Yes. pytest-qt is production-stable (since 2013), actively maintained, has no known vulnerabilities, and installs with low friction. Install it if you're testing PyQt or PySide applications and want pytest-native fixtures for widget interaction and signal handling. The only prerequisite is having one of PyQt5, PyQt6, or PySide6 already available.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires PyQt5, PyQt6, or PySide6 to be installed separately; pytest-qt will auto-detect or you can set qt_api in pytest.ini or PYTEST_QT_API environment variable.
- Low friction install with stable maintenance: the package is actively maintained (last commit 2026-08-03), has been in production since 2013, and depends only on pytest, pluggy, and typing_extensions—all widely available.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use this package in commercial or proprietary projects with minimal restrictions, provided you include the license notice.
last release 2025-07-01 (409 days) · last repo commit 2026-08-03 · 455 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,187,026 downloads/mo, #4,247 on PyPI
Alternatives
Verify before relying
pip install pytest-qt
# In your test file:
def test_widget(qtbot):
widget = MyWidget()
qtbot.addWidget(widget)
qtbot.mouseClick(widget.button, qt_api.QtCore.Qt.MouseButton.LeftButton)- Whether the package handles headless/CI environments without additional configuration beyond pytest-xvfb.
- Performance characteristics when testing large widget hierarchies or many signals.
- Compatibility guarantees across PyQt5/PyQt6/PySide6 API differences in test code.
What it is and what it does
pytest-qt bridges pytest and Qt application testing by providing the qtbot fixture, which manages Qt application lifecycle and exposes methods to simulate user interactions like mouse clicks and key presses. It also captures Qt debug/warning/critical messages automatically and provides waitSignal/waitSignals functions to block tests until specific signals are emitted, plus automatic exception handling in virtual methods and slots.
The plugin auto-detects which Qt library (PySide6, PyQt6, or PyQt5) is available or already imported, or lets you force a choice via pytest.ini or environment variable. It's designed for developers who need to verify that the view layer of a Qt application behaves correctly after code changes, without requiring manual GUI interaction.
Use it for
- Test button clicks and user input on PyQt5/PyQt6/PySide6 widgets to verify UI state changes.
- Verify that Qt signals are emitted at the right time using waitSignal/waitSignals in your test suite.
- Capture and assert on qDebug, qWarning, and qCritical messages emitted during widget operations.
- Validate exception handling in Qt virtual methods and slots by letting pytest-qt catch and report them.
- Automate GUI regression testing in CI pipelines by simulating user interactions programmatically.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
pytest-qt is production-stable (since 2013), actively maintained, has no known vulnerabilities, and installs with low friction. Install it if you're testing PyQt or PySide applications and want pytest-native fixtures for widget interaction and signal handling. The only prerequisite is having one of PyQt5, PyQt6, or PySide6 already available.
Install
pytest-qt on PyPI
Before you install
Low friction install with stable maintenance: the package is actively maintained (last commit 2026-08-03), has been in production since 2013, and depends only on pytest, pluggy, and typing_extensions—all widely available.
Requires PyQt5, PyQt6, or PySide6 to be installed separately; pytest-qt will auto-detect or you can set qt_api in pytest.ini or PYTEST_QT_API environment variable.
License in practice
MIT license is permissive; you can use this package in commercial or proprietary projects with minimal restrictions, provided you include the license notice.
Quickstart
pip install pytest-qt
# In your test file:
def test_widget(qtbot):
widget = MyWidget()
qtbot.addWidget(widget)
qtbot.mouseClick(widget.button, qt_api.QtCore.Qt.MouseButton.LeftButton)
Verify before relying
- Whether the package handles headless/CI environments without additional configuration beyond pytest-xvfb.
- Performance characteristics when testing large widget hierarchies or many signals.
- Compatibility guarantees across PyQt5/PyQt6/PySide6 API differences in test code.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 3 packagespytestpluggytyping_extensions |
| Maintenance | Actively maintained 409 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,187,026 / month, #4,247 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Desktop Environment :: Window ManagersTopic :: Software Development :: Quality AssuranceTopic :: Software Development :: TestingTopic :: Software Development :: User Interfaces |
Evidence: pytest_qt-4.5.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “pytest qt testing”
- pytest-qtpytest-qt is a pytest plugin that provides fixtures and utilities to…
- QtPyQtPy provides a unified API for writing Qt applications that work…
- aqtaqt is the Qt-based desktop GUI for Anki, the spaced repetition…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.
Install it if you write tests for any asyncio-based code.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
See also pytest-selenium · QtPy · pyqt5-tools · pytest-rabbitmq · pytest-redis · pytest-aiohttp · tdd-guard-pytest · qtconsole · pytest-django