光子科学探测器的实时图像查看器应用。

qtchecker的Python项目详细描述


作者:Jan Kotanïski<;简·科坦斯基在desy.de>

简介

这是一个简单的助手模块,用于执行PyQt GUI测试。在

使用qtchecker模块作为其用户

  1. 使用全局QApplication对象和给定的测试过的QWidget对话框参数创建QtChecker对象
  2. 使用setChecks()方法和以下帮助程序类定义检查序列:
  • AttrCheck-读取测试的对话框属性值
  • CmdCheck-执行一个经过测试的对话框命令并读取其结果值
  • WrapAttrCheck-对测试的对话框属性执行包装器命令
  • WrapCmdCheck-对测试的对话框命令的结果值执行包装命令
  • ExtAttrCheck-读取在对话框外部定义的外部属性值
  • ExtCmdCheck-执行在对话框外部定义的外部命令并读取其结果值
  1. 启动事件循环并使用executeChecks()executeChecksAndClose()方法执行检查
  2. 通过读取执行的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包:qt4qt5pyqtgraph。在

来源

https://github.com/jkotan/qtchecker下载最新的QtChecker版本

提取源并运行

^{pr2}$

setup.py脚本可能需要:setuptools  sphinxpython包以及qtbase5-dev-toolslibqt4-dev-bin。在

Debian软件包

Debianbusterstretch或Ubuntufocaleoanbionic包可以在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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java不兼容类型:MainActivity无法转换为LifecycleOwner   java安卓是一种更有效的读取大文本文件的方法   java导出LWJGL本地人与项目?(IntelliJ IDEA)   JDK更新后,JavaJShell不再在下一行打印输出   父类对象上的继承Java比较子属性   Java:有没有一个容器可以有效地结合HashMap和ArrayList?   安卓 Java对象指针   java在annotationdriven Spring MVC应用程序中实现大气   java 安卓源代码构建应用找不到安卓supportv4。罐子   文件系统上的抽象层和Java中的jar/zip   java在水平滚动视图中添加多个图像?   java如何从firebase实时数据库中获取字符串数组   WIndows 10工作站上的java未满足链接错误   java命令在终端中工作,但在使用过程中出现“无结束引号”错误。执行官