[Qgis-developer] How to debug and unit test Python plugins
outside QGIS (e.g. in Ecplise IDE + PyDev)
Martin Dobias
wonder.sk at gmail.com
Thu Mar 3 03:40:06 EST 2011
On Thu, Mar 3, 2011 at 12:57 AM, Stefan Keller <sfkeller at gmail.com> wrote:
> Hi,
>
> I'm new to writing Python plugins for QGIS and I like to debug and
> unit test theses outside QGIS runtime but don't see any instructions
> on how to do this.
>
> Of course, the ultimate test of any plugin is to run it inside QGIS.
> But I'd like do that outside QGIS for example in Eclipse IDE (+ PyDev)
> in order to get code-completion, to debug it and to write unit tests
> on it.
>
> The problem is that one gets "ImportError: No module named ..." with
> mostly PyQt4/qgis modules which (of course) cannot be imported.
Hi Stefan
I think most of the relevant information is covered in the cookbook:
http://www.qgis.org/pyqgis-cookbook/intro.html#python-applications
I hope PyDev has a configuration dialog where you can add your custom
python paths to avoid these import errors.
The only difference when running unit-tests (i.e. standalone apps) is
that you cannot access QGIS interface (qgis.utils.iface) since there
is no QGIS running. But that should not pose a big problem. In case
you really need access to that interface you can create your own
implementation of QgisInterface class and assign it to
qgis.utils.iface.
Regards
Martin
More information about the Qgis-developer
mailing list