[TIP] Unit and Acceptance testing WxPython

Stefano Masini stefano.masini at pragma2000.com
Sun Apr 27 03:40:08 PDT 2008


On Sun, Apr 27, 2008 at 3:14 AM, Nate Lowrie <solodex2151 at gmail.com> wrote:
>  I haven't gotten any responses, but I figured it out.  I am design the
>  GUI as a Humble Dialog.  Essentially, it's a MVC architecture in which
>  the view is as thin a wrapper is possible, with all of the logic
>  implemented in the controller, which is testable.  It has been working
>  out really well so far.  Also, I sort of lied when I said I am using
>  WxPython.  I am actually using Dabo, which is a Pythonic wrapper over
>  WxPython.  The reason I mention this is that the Dabo UI syntax
>  results in far less code to create the same application.  So, I can
>  minimize the view code which means less code overall that is untested.
>   If there is interest I could write an article and post it to my
>  website.

Hi Nate,

I've done wxPython testing in the past, using the Humble Dialog pattern too.
I too was excited in the beginning. What I liked most was the fact
that while coding I was "envisioning" my UI, rather than actually
"visioning" it. I could leave the actual UI "wiring" as the very last
step, when all the logic was written and tested, so when I finally saw
my UI, it was already perfectly functional, with all corner cases
handled, and so forth.

But... :)

... after a few months I figured that the real meat of my application
was not near the UI, but much closer to the backend. It was far in the
back that I really needed the added robustness of unit testing.
Instead, having the UI so heavily glued to my tests, so artificially
separated into such a thin MVC just for the sake of testability didn't
add so much value to my project. Rather, all those tests written on a
preliminary version of the UI just slowed down the unavoidable
refacing of the app that the customer requested after seeing it.

In the end I decided that unit testing so close to the UI library was
overkill for me, and I preferred to code without unit testing there. I
simply moved the border of unit testing a little closer to the
backend, and left some space for "cowboy coding" right where it was
more likely that the customer asked on a daily basis to change small
stuff here and there. After all bugs where not so frequent.

My 2 cents.
Stefano



More information about the testing-in-python mailing list