Questions tagged [pytest-qt]

pytest-qt is a pytest plugin that allows programmers to write tests for PySide, PySide2 and PyQt applications.

35 questions
5
votes
1 answer

How to click on QMessageBox with pytest-qt?

I am creating some unit tests for a PyQt application with pytest-qt. And I would like to create open the graphical window, do some tests then close the window, rather than open a new window for every test, ie. use a module fixture for the window…
R. N
  • 707
  • 11
  • 31
4
votes
1 answer

Can't create (python) QApplication in github action

I've got some unit tests for my (python) Qt gui, which require QApplication instance, but creating one always fail for me (i.e. ends in core dumped and application abort at line with QApplication()). What I've tried so far is: creation…
konserw
  • 494
  • 2
  • 10
4
votes
1 answer

Selecting QListWidgetItem with qtbot.mouseClick

How can I click on a QListWidgetItem with qtbot.mouseClick? I tried it with the following code, but it fails on the final assert: from PySide2 import QtWidgets, QtCore import pytest @pytest.fixture def widget(qtbot): widget =…
rmweiss
  • 716
  • 1
  • 6
  • 16
3
votes
0 answers

How to press the okay button using pytest-qt whilst testing a pyqt5 app?

How can I "okay" a QMessageBox using pytestqt? For instance, given: # MessageBoxFactory.py from PyQt5.QtWidgets import QMessageBox, QWidget def messageBoxFactory(parent : QWidget, title:str, msg:str, level="info"): """Display a popup of type…
CiaranWelsh
  • 7,014
  • 10
  • 53
  • 106
3
votes
0 answers

How to test a PyQt5 QApplication using pytest and pytest-qt?

I am trying to test my QtApplication using pytest-qt and need some assistance with the basics. Give a simple mwe such as this: # mwe.py import sys from PyQt5.QtWidgets import (QWidget, QToolTip, QPushButton, QApplication) from PyQt5.QtGui import…
CiaranWelsh
  • 7,014
  • 10
  • 53
  • 106
3
votes
3 answers

Fatal Python Error when running pytest with QT

I'm new to pytest and I'm having trouble trying to run one of my test files. I'm getting the following output: ================================================== test session starts ================================================== platform linux…
3
votes
1 answer

How to automate mouse drag using pytest-qt?

I have a pyqt window which tracks mouse movement while the mouse is pressed. I'm trying to write a test to automate this movement using pytest-qt. Here is an example class: from PyQt5.QtWidgets import * from PyQt5.QtGui import QCursor from…
Evan Brittain
  • 547
  • 5
  • 15
3
votes
2 answers

Running pytest-qt on CircleCI

I am attempting to run tests which require pytest-qt (for testing PySide2 dialogs) on CircleCI. I am getting the following error: xdpyinfo was not found, X start can not be checked! Please install xdpyinfo! ============================= test session…
user6152171
3
votes
2 answers

QApplication instance/qtbot fixture causes travis-ci to abort and core dump

Working on understanding how to go about automated unit testing for PySide2-based applications. However, whenever I attempt to initialize a QApplication instance within the tests, be it through PySide2 itself or through pytest-qt's qtbot fixture,…
3
votes
1 answer

How to handle modal dialog in pytest-qt without mocking the dialog

I am using pytest-qt to automate the testing of a PyQt GUI. The dialogs need to be handled as a part of the testing(dialogs should not be mocked). For example, file dialog that comes after a button-click has to be handled. There are 2…
3
votes
2 answers

simulating mouse click in menu bar and toolbar using Qtbot

I'm automation a notepad GUI developed in PYQT5 using PYtestqt. when I try to click the menu bar or toolbar options using qtbot it is not simulating the click def test_quit(qtbot): window = MainWindow() qtbot.add_widget(window) …
2
votes
1 answer

"This plugin does not support propagateSizeHints()" / calling `exec` on QDialog subclass

NB OS is W10. The context here is pytest-qt. I found this answer and tried to use it (see later). I get this error when a test method calls an application method which creates a QFileDialog and then calls exec on it. The console then puts out this…
mike rodent
  • 14,126
  • 11
  • 103
  • 157
2
votes
1 answer

How to select an item in a QTableWidget using pytest-qt mouse click?

I have a table in my main GUI. I want to test my ability to delete items in the table using a menu that comes up upon right-clicking on an item. I'm using pytest-qt to conduct testing. Using qtbot.mouseClick seems to work well when clicking on…
2
votes
1 answer

How to check correct opening the window after the click by button in pytest-qt

I want to test a module in my project, but I have a some problem with it. I don't know how I can check the correct opening of the window after the button click. I have the windows SelectAddingBookTypeWindow and AddSchoolBookWindow. I want to check…
dgonkaries
  • 23
  • 5
1
vote
1 answer

How to use QtBot.waitSignal() in pytest-qt?

I am using pytest-qt and its waitSignal() method to test a QDialog but it is not working. Here is a minimal example (my real application is more complex): import sys from PyQt6.QtWidgets import ( QApplication, QDialog, QGridLayout,…
Håkon Hægland
  • 39,012
  • 21
  • 81
  • 174
1
2 3