[PyQt] Testing a standalone dialog widget
bjones at ece.msstate.edu
Mon Jan 12 21:54:31 GMT 2015
Thanks for the comments, particuarly the reminder on the difficult of
combining unit tests in Python with the QTest interface. What works for me
when testing: make the QApplication instance a module-level variable. Yes,
this isn't the right way to do things for traditional application...but it
works fine when testing for me. I'd be interested to hear others' comments.
Specifically, referring to the test code:
http://johnnado.com/pyqt-qtest-example/ for docs,
https://bitbucket.org/jmcgeheeiv/pyqttestexample for the code
Change MargaritaMixerTest.py starting at line 39 to be...
# This is new
app = QApplication(sys.argv)
'''Test the margarita mixer GUI'''
'''Create the GUI'''
# Commented out: self.app = QApplication(sys.argv)
self.form = MargaritaMixer.MargaritaMixer()
..the rest of the code is the same...
On Tue, Dec 30, 2014 at 2:03 AM, Antonio Valentino <
antonio.valentino at tiscali.it> wrote:
> Hi David, hi Andre,
> Il 29/12/2014 23:51, Andre Roberge ha scritto:
> > On Mon, Dec 29, 2014 at 6:41 PM, David Cortesi <davecortesi at gmail.com>
> > wrote:
> >> From: Antonio Valentino <antonio.valentino at tiscali.it>
> >>> I'm very interested in this topic so if anyone has some useful pointers
> >>> to material about unittesting of PyQt based GUI applications please
> >> I have found Sikuli (http://www.sikuli.org/) useful for this. You can
> >> up quite complex scenarios and validate the GUI response.
> >> A Sikuli script is a Python script. Basically you start one off with
> >> subprocess.Popen(['/usr/local/bin/python', 'path-to-test-driver.py'])
> >> and then continue with Sikuli statements to click, or type, or look for
> >> specific visual items in the UI presented by the test-driver.py
> >> There is an interactive tool for dragging to select particular bits of
> >> a menu or a dialog or whatever, and say "expect that here".
> > In my original post on this topic, I mentioned that I was using pyautogui
> > which works (I thought) similarly to Sikuli. The problem with this
> > approach is that one pretty much has to leave the monitor alone while the
> > tests are run and it might be difficult to set thing up with automated
> > testing providers (like https://travis-ci.org/). Since PyQt includes
> > QTest, I was thinking that there had to be many people using it and that
> > there should be some relatively easy/standard ways of doing unittesting
> > with QTest.
> I totally agree
> > However... you do write that you have found Sikuli useful. Is there some
> > relatively straightforward way to run tests quickly with Sikuli so that
> > does not interrupt the workflow significantly (which I found pyautogui
> > doing.)
> > André
> Thanks, I will give a look to both Sikuli and pyautogui.
> best ragards
> Antonio Valentino
> PyQt mailing list PyQt at riverbankcomputing.com
Bryan A. Jones, Ph.D.
Department of Electrical and Computer Engineering
231 Simrall / PO Box 9571
Mississippi State University
Mississippi state, MS 39762
bjones AT ece DOT msstate DOT edu
Our Master, Jesus Christ, is on his way. He'll show up right on
time, his arrival guaranteed by the Blessed and Undisputed Ruler,
High King, High God.
- 1 Tim. 6:14b-15 (The Message)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyQt