[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Testing a standalone dialog widget
From:       "Jones, Bryan" <bjones () ece ! msstate ! edu>
Date:       2015-01-12 21:54:31
Message-ID: CAHhYbD8U1D5qUN25FaZ7vGZwgW_Uy8EX77jQYkWcAc2ZPg6LNg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


All,

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)

class MargaritaMixerTest(unittest.TestCase):
    '''Test the margarita mixer GUI'''
    def setUp(self):
        '''Create the GUI'''
        # Commented out: self.app = QApplication(sys.argv)
        self.form = MargaritaMixer.MargaritaMixer()

..the rest of the code is the same...

Bryan



On Tue, Dec 30, 2014 at 2:03 AM, Antonio Valentino <
antonio.valentino@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@gmail.com>
> > wrote:
> >
> >>
> >> From: Antonio Valentino <antonio.valentino@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
> share.
> >>>
> >>
> >> I have found Sikuli (http://www.sikuli.org/) useful for this. You can
> set
> >> 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
> execution.
> >> There is an interactive tool for dragging to select particular bits of
> UI,
> >> 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
> it
> > does not interrupt the workflow significantly (which I found pyautogui
> was
> > doing.)
> >
> > André
> >
>
> Thanks, I will give a look to both Sikuli and pyautogui.
>
> best ragards
>
> --
> Antonio Valentino
> _______________________________________________
> PyQt mailing list    PyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>



-- 
Bryan A. Jones, Ph.D.
Associate Professor
Department of Electrical and Computer Engineering
231 Simrall / PO Box 9571
Mississippi State University
Mississippi state, MS 39762
http://www.ece.msstate.edu/~bjones
bjones AT ece DOT msstate DOT edu
voice 662-325-3149
fax 662-325-2298

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)

[Attachment #5 (text/html)]

<div dir="ltr">All,<br><br>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&#39;t the right way to do things for traditional application...but it works fine \
when testing for me. I&#39;d be interested to hear others&#39; \
comments.<br><div><br></div><div>Specifically, referring to the test \
code:</div><div><a href="http://johnnado.com/pyqt-qtest-example/">http://johnnado.com/pyqt-qtest-example/</a> \
for docs,<br></div><div><a \
href="https://bitbucket.org/jmcgeheeiv/pyqttestexample">https://bitbucket.org/jmcgeheeiv/pyqttestexample</a> \
for the code<br></div><div><br></div><div>Change MargaritaMixerTest.py starting at \
line 39 to be...</div><div><br></div><div># This is new<br></div><div><div>app = \
QApplication(sys.argv)   </div><div><br></div><div>class \
MargaritaMixerTest(unittest.TestCase):</div><div>      &#39;&#39;&#39;Test the \
margarita mixer GUI&#39;&#39;&#39;</div><div>      def setUp(self):</div><div>        \
&#39;&#39;&#39;Create the GUI&#39;&#39;&#39;</div><div>            # Commented out: \
self.app = QApplication(sys.argv)</div><div>            self.form = \
MargaritaMixer.MargaritaMixer()</div><div><br></div><div>..the rest of the code is \
the same...</div><div><br></div><div>Bryan</div><div><br></div></div><div><br></div></div><div \
class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 30, 2014 at 2:03 AM, \
Antonio Valentino <span dir="ltr">&lt;<a href="mailto:antonio.valentino@tiscali.it" \
target="_blank">antonio.valentino@tiscali.it</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">Hi David, hi Andre,<br> <br>
Il 29/12/2014 23:51, Andre Roberge ha scritto:<br>
<span class="">&gt; On Mon, Dec 29, 2014 at 6:41 PM, David Cortesi &lt;<a \
href="mailto:davecortesi@gmail.com">davecortesi@gmail.com</a>&gt;<br> &gt; wrote:<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; From: Antonio Valentino &lt;<a \
href="mailto:antonio.valentino@tiscali.it">antonio.valentino@tiscali.it</a>&gt;<br> \
&gt;&gt;&gt; I&#39;m very interested in this topic so if anyone has some useful \
pointers<br> &gt;&gt;&gt; to material about unittesting of PyQt based GUI \
applications please share.<br> &gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; I have found Sikuli (<a href="http://www.sikuli.org/" \
target="_blank">http://www.sikuli.org/</a>) useful for this. You can set<br> &gt;&gt; \
up quite complex scenarios and validate the GUI response.<br> &gt;&gt;<br>
&gt;&gt; A Sikuli script is a Python script. Basically you start one off with<br>
&gt;&gt;<br>
&gt;&gt; subprocess.Popen([&#39;/usr/local/bin/python&#39;, \
&#39;path-to-test-driver.py&#39;])<br> &gt;&gt;<br>
&gt;&gt; and then continue with Sikuli statements to click, or type, or look for<br>
&gt;&gt; specific visual items in the UI presented by the test-driver.py \
execution.<br> &gt;&gt; There is an interactive tool for dragging to select \
particular bits of UI,<br> &gt;&gt; a menu or a dialog or whatever, and say \
&quot;expect that here&quot;.<br> &gt;&gt;<br>
&gt;<br>
&gt; In my original post on this topic, I mentioned that I was using pyautogui<br>
&gt; which works (I thought) similarly to Sikuli.   The problem with this<br>
&gt; approach is that one pretty much has to leave the monitor alone while the<br>
&gt; tests are run and it might be difficult to set thing up with automated<br>
&gt; testing providers (like <a href="https://travis-ci.org/" \
target="_blank">https://travis-ci.org/</a>).     Since PyQt includes<br> &gt; QTest, \
I was thinking that there had to be many people using it and that<br> &gt; there \
should be some relatively easy/standard ways of doing unittesting<br> &gt; with \
QTest.<br> <br>
</span>I totally agree<br>
<span class=""><br>
&gt; However... you do write that you have found Sikuli useful. Is there some<br>
&gt; relatively straightforward way to run tests quickly with Sikuli so that it<br>
&gt; does not interrupt the workflow significantly (which I found pyautogui was<br>
&gt; doing.)<br>
&gt;<br>
&gt; André<br>
&gt;<br>
<br>
</span>Thanks, I will give a look to both Sikuli and pyautogui.<br>
<br>
best ragards<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Antonio Valentino<br>
</font></span><div class="HOEnZb"><div \
class="h5">_______________________________________________<br> PyQt mailing list      \
<a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br> <a \
href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" \
target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></div></div></blockquote></div><br><br \
clear="all"><div><br></div>-- <br><div class="gmail_signature">Bryan A. Jones, \
Ph.D.<br>Associate Professor<br>Department of Electrical and Computer \
Engineering<br>231 Simrall / PO Box 9571<br>Mississippi State \
University<br>Mississippi state, MS 39762<br><a \
href="http://www.ece.msstate.edu/~bjones" \
target="_blank">http://www.ece.msstate.edu/~bjones</a><br>bjones AT ece DOT msstate \
DOT edu<br>voice 662-325-3149<br>fax 662-325-2298<br><br>Our Master, Jesus Christ, is \
on his way. He&#39;ll show up right on<br>time, his arrival guaranteed by the Blessed \
and Undisputed Ruler,<br>High King, High God.<br>- 1 Tim. 6:14b-15 (The \
Message)<br></div> </div>


[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic