[PySide] Fwd: Creating and deleting instances of QApplication within unit tests

Dan McCombs dmccombs at dyn.com
Fri Oct 25 21:13:10 CEST 2013


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:

http://stuvel.eu/blog/127/multiple-instances-of-qapplication-in-one-process

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.quit()
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?

Thanks,

-Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20131025/39227480/attachment.html>


More information about the PySide mailing list