I am new to PyQt, but I am going to use pytest with pytest-qt plugin to test my PyQt5 application. I had some GUI testing experience in Java with SWTBot and RCPTT, where I could see what happens with controls and whole GUI during the test in real-time. I'd like to have such behavior with my new python tools, but it seems that pytest-qt tests GUI in some background way. All code works as I expect, but during testing I can't see the GUI. The code is simple as in tutorials:
from tests.test import MyApp
from time import sleep
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
def test_myapp(qtbot):
app = QApplication([])
window = MyApp()
# window.show()
# app.exec_()
qtbot.addWidget(window)
qtbot.mouseClick(window.buttonBox.buttons()[0], Qt.LeftButton)
sleep(5)
assert window.label.text() == 'accept'
If I uncomment the window.show() line (they do so in the tutorial), I can see a strange window, that contains frozen background:
I suppose that it is theoretically possible to show the interface because I know that PyQt5 works from the python shell (more):
you can, for example, create widgets from the Python shell prompt, interact with them, and still being able to enter other Python commands
But I don't know how to achieve it with pytest-qt
