_base.py 851 B

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