[PySide] Creating and deleting instances of QApplication within unit tests
dmccombs at dyn.com
Sat Oct 26 14:01:40 CEST 2013
Yes, the first thing I tried was:
app = QtGui.QApplication()
But, the next test raises the exception about there already being a
QApplication instance when it runs that first line. That's why I resorted
to poking around trying to figure out where PySide is keeping track of that
original instance causing it to raise that exception.
Senior Software Engineer / Dyn
Are you prepared for website disaster? Find out in two minutes:
On Fri, Oct 25, 2013 at 3:13 PM, Dan McCombs <dmccombs at dyn.com> wrote:
> Hey all,
> I've been struggling with unit testing my PySide application. My tests run
> fine, but if I have more than one test, Python segfaults on quit. It seems
> the solution would be to destroy/create the QApplication instance on each
> test run, as I've seen people mentioning in the case of PyQT such as:
> I've tried doing something similar in PySide with the following lines in
> my setUp for each test:
> QtGui.qApp = QtGui.QApplication()
> And the following in my tearDown:
> QtGui.qApp = none
> However, the instance still exists (I can get it via
> QtGui.QApplication.instance()) and when the second test setUp starts to
> run, I get an exception that "A QApplication instance already exists.".
> How can I fully remove the QApplication instance between tests?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PySide