On Thu, Sep 24, 2020 at 9:36 AM Ian Turton <ijtur...@gmail.com> wrote: > > I was toying with refactoring my plugin code the other day, but I thought I > would add some unit tests using pytest before I started to make sure I didn't > break anything. But when I try something like: > > def test_convertGridRef(): > QgsExpression.registerFunction(convertGridRef) > e = QgsExpression('convertGridRef("SE2720")') > assert e.evaluate(None) == 'POINT (427000 420000)' > > e.evaluate returns None - when it should either return a point or an exception > > Does anyone have some good plugin unit test examples I can take a look at? >
Hi Jan, There are many possible approaches to plugin testing, one of the most interesting IMO is to use the testing docker which allows you to run the tests inside a real QGIS instance and not a mocked one. You can find examples of this setup in https://github.com/inasafe/inasafe/blob/develop/.travis.yml and there is some documentation in https://github.com/qgis/QGIS/tree/master/.docker#running-unit-tests-inside-qgis Hope this helps. -- Alessandro Pasotti QCooperative: www.qcooperative.net ItOpen: www.itopen.it _______________________________________________ Qgis-user mailing list Qgis-user@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user