_base.py 877 B

123456789101112131415161718192021222324252627282930313233
  1. '''
  2. @author: olivier.massot, 2019
  3. '''
  4. from core import mncheck
  5. from qgis.core import QgsProject
  6. import unittest
  7. class SchemaTest(unittest.TestCase):
  8. SCHEMA_NAME = ""
  9. PROJECT_FILE = ""
  10. @classmethod
  11. def setUpClass(cls):
  12. if cls.PROJECT_FILE:
  13. cls._open_qgs_project(cls.PROJECT_FILE)
  14. @classmethod
  15. def tearDownClass(cls):
  16. if cls.PROJECT_FILE:
  17. cls._close_qgs_project()
  18. @classmethod
  19. def _open_qgs_project(cls, filename):
  20. QgsProject.instance().clear()
  21. ok = QgsProject.instance().read(filename)
  22. if not ok:
  23. raise IOError("Error while loading the qgis project {}: {}".format(cls.PROJECT_FILE, QgsProject.instance().error()))
  24. @classmethod
  25. def _close_qgs_project(cls):
  26. QgsProject.instance().clear()