Esempio n. 1
0
    from qgis.utils import iface

    class QgsProjectBadLayerDefaultHandler(QgsProjectBadLayerHandler):
        def handleBadLayers(self, layers, dom):
            pass

    # Monkey patch QGIS Python console
    from console.console_output import writeOut

    def _write(self, m):
        sys.__stdout__.write(m)

    writeOut.write = _write

    # Add current working dir to the python path
    sys.path.append(QDir.current().path())

    def __run_test():
        """
        Run the test specified as last argument in the command line.
        """
        # Disable modal handler for bad layers
        QgsProject.instance().setBadLayerHandler(
            QgsProjectBadLayerDefaultHandler())
        eprint("QGIS Test Runner Inside - starting the tests ...")
        try:
            test_module_name = QgsApplication.instance().arguments()[-1]
            function_name = __get_test_function(test_module_name)
            eprint("QGIS Test Runner Inside - executing function %s" %
                   function_name)
            function_name()
Esempio n. 2
0
    from qgis.PyQt.QtCore import QDir
    from qgis.utils import iface

    class QgsProjectBadLayerDefaultHandler(QgsProjectBadLayerHandler):
        def handleBadLayers(self, layers, dom):
            pass

    # Monkey patch QGIS Python console
    from console.console_output import writeOut

    def _write(self, m):
        sys.__stdout__.write(m)
    writeOut.write = _write

    # Add current working dir to the python path
    sys.path.append(QDir.current().path())

    def __run_test():
        """
        Run the test specified as last argument in the command line.
        """
        # Disable modal handler for bad layers
        QgsProject.instance().setBadLayerHandler(QgsProjectBadLayerDefaultHandler())
        eprint("QGIS Test Runner Inside - starting the tests ...")
        try:
            test_module_name = QgsApplication.instance().arguments()[-1]
            function_name = __get_test_function(test_module_name)
            eprint("QGIS Test Runner Inside - executing function %s" % function_name)
            function_name()
        except Exception as e:
            eprint("QGIS Test Runner Inside - [FAILED] Exception: %s" % e)