Graphics Reference
In-Depth Information
# ...
QgsApplication.exitQgis()
You will also need to use an appropriate wrapper script, as described in Chapter 1 , Getting
Started with QGIS , so that the Python path and other environment variables are set cor-
rectly.
With QGIS unit tests, you have to set up the QGIS environment before the test is run, and
then shut it down again once the test finishes. This is done by placing the appropriate parts
of the boilerplate code into the unit test's setup() and tearDown() methods, like
this:
import unittest
import os
from qgis.core import *
class MyTest(unittest.TestCase):
def setup(self):
QgsApplication.setPrefixPath(os.environ['QGIS_PREFIX'],
True)
QgsApplication.initQgis()
def tearDown(self):
QgsApplication.exitQgis()
def test_plugin(self):
...
You can then import and test your plugin's Python code within the test_plugin()
method.
Search WWH ::




Custom Search