Package: qtchecker
Authors: Jan Kotański <jan.kotanski at desy.de>IntroductionThis is a simple helper module to perform PyQt GUI tests.Source code:https://github.com/jkotan/qtcheckerProject Web page:https://jkotan.github.io/qtcheckerWith theqtcheckermodule its usercreatesQtCheckerobject  with the global QApplication object and a given tested QWidget dialog parametersdefines a sequence of checks withsetChecks()method and the following helper classes:AttrCheck- read a tested dialog attribute valueCmdCheck- execute a tested dialog command and read its result valueWrapAttrCheck- execute a wrapper command on a tested dialog attributeWrapCmdCheck- execute a wrapper command on a result value of a tested dialog commandExtAttrCheck- read an external attribute value defined outside the dialogExtCmdCheck- execute an external command defined outside the dialog and read its result valuestarts event loop and performs checkes withexecuteChecks()orexecuteChecksAndClose()methodcompare results by readingresultsattribute of executingfor exampleimportunittestfromPyQt5importQtGuifromPyQt5importQtCorefromPyQt5importQtTestfromqtchecker.qtCheckerimportQtChecker,CmdCheck,WrapAttrCheck,ExtCmdCheck# import my dialog modulefromlavuelibimportliveViewer# QApplication object should be one for all tessapp=QtGui.QApplication([])classGuiTest(unittest.TestCase):def__init__(self,methodName):unittest.TestCase.__init__(self,methodName)deftest_run(self):# my tested MainWindow dialogdialog=liveViewer.MainWindow()dialog.show()# create QtChecker objectqtck=QtChecker(app,dialog)# define a sequence of action of the dialogqtck.setChecks([# read return value of execute isConnected commandCmdCheck(# a python path to a method executed in the first action"_MainWindow__lavue._LiveViewer__sourcewg.isConnected"),# click pushButton with the left-mouse-clickWrapAttrCheck(# a python path to an pushButton object"_MainWindow__lavue._LiveViewer__sourcewg._SourceTabWidget__sourcetabs[],0._ui.pushButton",# Wrapper command to be executed on the action objectQtTest.QTest.mouseClick,# additional parameters of the wrapper command[QtCore.Qt.LeftButton]),# read a result of external "getLAvueState" commandExtCmdCheck(# parent object of the external commandself,# external command name"getLavueState"),])# execute the check actions and close the dialogstatus=qtck.executeChecksAndClose()self.assertEqual(status,0)# compare results returned by each actionqtck.compareResults(self,[# a result of isConnected() commandTrue,# a result of the mouseClick on the pushButtonNone,# a result of getLavueState() command'{"connected": false}'])defgetLavueState(self):""" an external command """importtangoreturntango.DeviceProxy("po/lavuecontroller/1").LavueStateMore examples can be found at likeLavueTestsorLavueStateTests.InstallationQtChecker requires the following python packages:qt4orqt5orpyqtgraph.From sourcesDownload the latest QtChecker version fromhttps://github.com/jkotan/qtcheckerExtract sources and run$pythonsetup.pyinstallThesetup.pyscript may need:setuptools  sphinxpython packages as well asqtbase5-dev-toolsorlibqt4-dev-bin.Debian packagesDebianbusterandstretchor Ubuntufocal,eoan,bionicpackages can be found in the HDRI repository.To install the debian packages, add the PGP repository key$sudosu$wget-q-O-http://repos.pni-hdri.de/debian_repo.pub.gpg|apt-keyadd-and then download the corresponding source list, e.g.$cd/etc/apt/sources.list.dand$wgethttp://repos.pni-hdri.de/buster-pni-hdri.listor$wgethttp://repos.pni-hdri.de/stretch-pni-hdri.listor$wgethttp://repos.pni-hdri.de/focal-pni-hdri.listrespectively.Finally,$apt-getupdate$apt-getinstallpython-qtchecker$apt-getupdate$apt-getinstallpython3-qtcheckerfor python 3 version.From pipTo install it from pip you need to install pyqt5 in advance, e.g.$python3-mvenvmyvenv$.myvenv/bin/activate$pipinstallpyqt5$pipinstallqtchecker