Ejemplo n.º 1
0
        eprint(out)
    if len(out) == 0:
        print("QGIS Test Runner - [WARNING] subprocess returned no output")
    print('='*60)

    print("QGIS Test Runner - %s bytes returned and finished with exit code: %s" % (len(out), 0 if ok else 1))
    sys.exit(0 if ok else 1)

else: # We are inside QGIS!
    # Start as soon as the initializationCompleted signal is fired
    from qgis.core import QgsApplication
    from PyQt.QtCore import QDir
    from qgis.utils import iface

    # 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.
        """
        eprint("QGIS Test Runner Inside - starting the tests ...")
        try:
            test_module_name = QgsApplication.instance().argv()[-1]
            function_name = __get_test_function(test_module_name)
            if function_name is None:
                eprint("QGIS Test Runner Inside - [ERROR] cannot load test function from %s" % test_module_name)
            function_name()
        except Exception, e:
            eprint("QGIS Test Runner Inside - [ERROR] Exception: %s" % e)
        app = QgsApplication.instance()