''' @author: olivier.massot, 2019 ''' from qgis.core import QgsProject import unittest class SchemaTest(unittest.TestCase): SCHEMA_NAME = "" PROJECT_FILE = "" @classmethod def setUpClass(cls): if cls.PROJECT_FILE: cls._open_qgs_project(cls.PROJECT_FILE) @classmethod def tearDownClass(cls): if cls.PROJECT_FILE: cls._close_qgs_project() @classmethod def _open_qgs_project(cls, filename): QgsProject.instance().clear() ok = QgsProject.instance().read(filename) if not ok: raise IOError("Error while loading the qgis project {}: {}".format(cls.PROJECT_FILE, QgsProject.instance().error())) @classmethod def _close_qgs_project(cls): QgsProject.instance().clear()