pytest-qt is a pytest plugin that allows programmers to write tests for PySide, PySide2 and PyQt applications.
Questions tagged [pytest-qt]
35 questions
1
vote
1 answer
Dialog button click in test not dismissing dialog PyQt5/pytest
When running a test that launches a dialog, the test is unable to programmatically click a button on the dialog. If I manually click the button, the test completes. Also I'm unsure why the dialog even shows at all (since I don't see the original…

user1102665
- 43
- 4
1
vote
0 answers
Pytest Error while Import "matplotlib.backends.backend_qt5agg" - pytest-qt
I have a created test file, test_sample.py. In that file I am trying to import the matplotlip package matplotlib.backends.backend_qt5agg, while running the pytest command it shows the following error. When I comment that import line, the pytest…

MOHAMED AZARUDEEN
- 151
- 1
- 11
1
vote
1 answer
How to make qtbot select an item from QComboBox?
I'm trying to develop a simple test application (using pytest) that tests an interface with many PyQt5 components (QLabel, QLineEdit, QCheckBox, QRadioButton and QComboBox), but I'm struggling with the combobox one.
How can I click on a QComboBox…

Ingridy Barreto
- 23
- 5
1
vote
1 answer
howto click on an menu entry with qtbot an pytest
with pycharm i created a small gui with pyqt5 and want to test with pytest and qtbot.
I have a problem to click a menu_entry within the menu and I could need a hint.
I looked at this very helpful post:
`pytestqt.mouseMove` to menubar menu widget…

thomas.tm
- 19
- 4
1
vote
2 answers
`pytest-qt` Function `mouseMove()` Not Working
This question has been asked here, here, here, here, and here and there is apparently still a bug regarding it in Qt5, noted here. So far, nothing I have found has solved my problem.
I am trying to test that when my mouse hovers over a toolbar…

adam.hendry
- 4,458
- 5
- 24
- 51
1
vote
1 answer
Why a Fatal Python error when testing using pytest-qt?
My first test using pytest-qt failed immediately with a Fatal Python error. I reduced the code to this (a test that would never pass, but shouldn't crash):
from PyQt5 import QtCore as qtc
class sut(qtc.QObject):
sig_sig_sputnik =…

Mike C
- 1,224
- 10
- 26
1
vote
1 answer
travis with pytest-qt fails without exiting nor creating QmessageBox
The context
I try to create an integration test for an graphical user interface (GUI) written with Qt5 through python3 (so using pyqt5).
And I use pytest with the plugging pytest-qt to test the GUI.
I test the GUI which here is largely inspired from…

R. N
- 707
- 11
- 31
1
vote
1 answer
How to test a custom dialog window called using exec_()?
I'm trying to write a system test for my project. I have a controller class which launches the various windows. However, I can't seem to control windows launch using exec with the qtbot.
Here is an MVCE:
from PyQt5.QtWidgets import *
from PyQt5…

Evan Brittain
- 547
- 5
- 15
1
vote
0 answers
Why can't pytest-qt find PyQt for Python 3.4?
I am using AppVeyor (Think Travis but for Windows) to run some tests again several different versions of Python. The tests depend on PyQt and pytest-qt. In some configurations, pytest-qt can't find PyQt, complaining:
pytest-qt requires either…

Oddthinking
- 24,359
- 19
- 83
- 121
0
votes
0 answers
pytest-qt: using qtbot gives segmentation fault
I am on Ubuntu 22.04, using Poetry, Python 3.10, PyQt6, and pytest with the pytest-qt plugin. When I run a test with pytest using the qtbot fixture I get a segmentation fault. If I remove the qtbot fixture from the test file, it works fine. Here is…

Håkon Hægland
- 39,012
- 21
- 81
- 174
0
votes
1 answer
pytest-qt to test menu functionality
I have a menu that I created
class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent=None)
...
create_menu_bar()
...
def create_menu_bar(self):
sheet_one = QtWidgets.QAction("sheet_one", self)
…

Willy
- 57
- 7
0
votes
0 answers
PyTest-qt handle QFileDialog automatically
I have a PySide6 application, for which I want to test that when cancelling the file dialog, nothing changes. Here is part of the function where the dialog is called:
def change_folder(self, side: int):
self.dialog = QFileDialog(self)
…

larrycaverga
- 1
- 1
0
votes
0 answers
pytest-qt waitSignal for long running computation running in a thread pool
I have successfully implemented a Python Qt app based off this very nice tutorial.
I am now writing tests using pytest-qt to specifically test a button that triggers a long running computation that eventually emits a signal when finished. I would…

Bastien Mazeran
- 71
- 1
- 4
0
votes
1 answer
How to Test that a PyQt button signal calls a function?
I have a PyQt5 GUI that calls a slot when I press a toolbar button. I know it works because the button itself works when I run the GUI. However, I cannot get my pytest to pass.
I understand that, when patching, I have to patch where the method is…

adam.hendry
- 4,458
- 5
- 24
- 51
0
votes
1 answer
Does the requests module play a part in pytest or pytest-qt?
This has cropped up in the course of some tests. I've tried to reproduce the problem in an MRE to isolate the problem but without success.
I have a test like this (simplified, but this simplified version manifests the same problem):
def…

mike rodent
- 14,126
- 11
- 103
- 157