光子科学探测器的实时图像查看器应用。
qtchecker的Python项目详细描述
作者:Jan Kotanïski<;简·科坦斯基在desy.de>
简介
这是一个简单的助手模块,用于执行PyQt GUI测试。在
使用qtchecker模块作为其用户
- 使用全局QApplication对象和给定的测试过的QWidget对话框参数创建QtChecker对象
- 使用setChecks()方法和以下帮助程序类定义检查序列:
- AttrCheck-读取测试的对话框属性值
- CmdCheck-执行一个经过测试的对话框命令并读取其结果值
- WrapAttrCheck-对测试的对话框属性执行包装器命令
- WrapCmdCheck-对测试的对话框命令的结果值执行包装命令
- ExtAttrCheck-读取在对话框外部定义的外部属性值
- ExtCmdCheck-执行在对话框外部定义的外部命令并读取其结果值
- 启动事件循环并使用executeChecks()或executeChecksAndClose()方法执行检查
- 通过读取执行的results属性来比较结果
例如
importunittestfromPyQt5importQtGuifromPyQt5importQtCorefromPyQt5importQtTestfromqtchecker.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").LavueState
更多的例子可以在likeLavueTests找到 或者LavueStateTests。在
安装
QtChecker需要以下python包:qt4或qt5或pyqtgraph。在
来源
从https://github.com/jkotan/qtchecker下载最新的QtChecker版本
提取源并运行
^{pr2}$setup.py脚本可能需要:setuptools sphinxpython包以及qtbase5-dev-tools或libqt4-dev-bin。在
Debian软件包
Debianbuster和stretch或Ubuntufocal,eoan,bionic包可以在HDRI存储库中找到。在
要安装debian包,请添加PGP存储库密钥
$ sudo su $ wget -q -O - http://repos.pni-hdri.de/debian_repo.pub.gpg | apt-key add -
然后下载相应的源代码列表,例如
$cd /etc/apt/sources.list.d
以及
$ wget http://repos.pni-hdri.de/buster-pni-hdri.list
或者
$ wget http://repos.pni-hdri.de/stretch-pni-hdri.list
或者
$ wget http://repos.pni-hdri.de/focal-pni-hdri.list
分别。在
最后
$ apt-get update $ apt-get install python-qtchecker
$ apt-get update $ apt-get install python3-qtchecker
对于python3版本。在
从pip
要从pip安装它,您需要提前安装pyqt5,例如
$ python3 -m venv myvenv $ . myvenv/bin/activate $ pip install pyqt5 $ pip install qtchecker
- 项目
标签: