Exemplo n.º 1
0
def run_suite(module, tests):
    """This allows for a list of test names to be selectively run.
    Also, ensures unittest verbose output comes at end, after debug output"""
    loader = unittest.defaultTestLoader
    if 'QGIS_TEST_SUITE' in os.environ and tests:
        suite = loader.loadTestsFromNames(tests, module)
    else:
        suite = loader.loadTestsFromModule(module)
    verb = 2 if 'QGIS_TEST_VERBOSE' in os.environ else 0

    out = StringIO.StringIO()
    res = unittest.TextTestRunner(stream=out, verbosity=verb).run(suite)
    if verb:
        print('\nIndividual test summary:')
    print('\n' + out.getvalue())
    out.close()

    if QGIS_TEST_REPORT and len(TESTREPORTS) > 0:
        teststamp = 'Local Server Test Report: ' + \
                    datetime.datetime.now().strftime('%Y-%m-%d %X')
        report = '<html><head><title>{0}</title></head><body>'.format(
            teststamp)
        report += '\n<h2>Failed Image Tests: {0}</h2>'.format(len(TESTREPORTS))
        for k, v in TESTREPORTS.iteritems():
            report += '\n<h3>{0}</h3>\n{1}'.format(k, v)
        report += '</body></html>'

        tmp = tempfile.NamedTemporaryFile(suffix=".html", delete=False)
        tmp.write(report)
        tmp.close()
        openInBrowserTab('file://' + tmp.name)

    return res
Exemplo n.º 2
0
def runSuite(module, tests):
    """This allows for a list of test names to be selectively run.
    Also, ensures unittest verbose output comes at end, after debug output"""
    loader = unittest.defaultTestLoader
    if 'PAL_SUITE' in os.environ:
        if tests:
            suite = loader.loadTestsFromNames(tests, module)
        else:
            raise Exception(
                "\n\n####__ 'PAL_SUITE' set, but no tests specified __####\n")
    else:
        suite = loader.loadTestsFromModule(module)
    verb = 2 if 'PAL_VERBOSE' in os.environ else 0

    res = unittest.TextTestRunner(verbosity=verb).run(suite)

    if PALREPORTS:
        teststamp = 'PAL Test Report: ' + \
                    datetime.datetime.now().strftime('%Y-%m-%d %X')
        report = '<html><head><title>{0}</title></head><body>'.format(teststamp)
        report += '\n<h2>Failed Tests: {0}</h2>'.format(len(PALREPORTS))
        for k, v in list(PALREPORTS.items()):
            report += '\n<h3>{0}</h3>\n{1}'.format(k, v)
        report += '</body></html>'

        tmp_name = getTempfilePath('html')
        with open(tmp_name, 'wt') as report_file:
            report_file.write(report)
        openInBrowserTab('file://' + tmp_name)

    return res
Exemplo n.º 3
0
def run_suite(module, tests):
    """This allows for a list of test names to be selectively run.
    Also, ensures unittest verbose output comes at end, after debug output"""
    loader = unittest.defaultTestLoader
    if 'QGIS_TEST_SUITE' in os.environ and tests:
        suite = loader.loadTestsFromNames(tests, module)
    else:
        suite = loader.loadTestsFromModule(module)
    verb = 2 if 'QGIS_TEST_VERBOSE' in os.environ else 0

    res = unittest.TextTestRunner(verbosity=verb).run(suite)

    if QGIS_TEST_REPORT and len(TESTREPORTS) > 0:
        teststamp = 'Local Server Test Report: ' + \
                    datetime.datetime.now().strftime('%Y-%m-%d %X')
        report = '<html><head><title>{0}</title></head><body>'.format(
            teststamp)
        report += '\n<h2>Failed Image Tests: {0}</h2>'.format(len(TESTREPORTS))
        for k, v in list(TESTREPORTS.items()):
            report += '\n<h3>{0}</h3>\n{1}'.format(k, v)
        report += '</body></html>'

        tmp_name = getTempfilePath("html")
        with open(tmp_name, 'wb') as temp_file:
            temp_file.write(report)
        openInBrowserTab('file://' + tmp_name)

    return res
Exemplo n.º 4
0
def run_all(): 
    loader = unittest.TestLoader()
    
    start_dir = os.path.dirname(__file__)
    suite = loader.discover(start_dir)
      
    runner = unittest.TextTestRunner(verbosity = 3, stream=sys.stdout)
    runner.run(suite)
Exemplo n.º 5
0
def run_all():
    suite = unittest.TestSuite()
    suite.addTests(unittest.makeSuite(TestInterface, 'test'))
    suite.addTests(unittest.makeSuite(TestImportAggregate, 'test'))
    suite.addTests(unittest.makeSuite(TestImportDetail, 'test'))
    suite.addTests(unittest.makeSuite(TestChartData, 'test'))
    suite.addTests(unittest.makeSuite(TestData, 'test'))
    unittest.TextTestRunner(verbosity=3, stream=sys.stdout).run(suite)
Exemplo n.º 6
0
def runTest(debug_mode=None):
    # python path setting
    plugins_dir = os.path.dirname(plugin_dir)
    sys.path.append(plugins_dir)

    if debug_mode is not None:
        conf.DEBUG_MODE = debug_mode
    print("DEBUG_MODE is {}.".format(conf.DEBUG_MODE))

    # initialize output directory
    from .utilities import initOutputDir
    initOutputDir()

    plugin_name = os.path.basename(plugin_dir)
    suite = unittest.TestLoader().discover(plugin_name + ".tests")
    unittest.TextTestRunner(verbosity=2).run(suite)
Exemplo n.º 7
0
def run_all():
    cov = coverage.Coverage(omit=[
        "*/usr/*",
        "*__init__.py",
        "*global_map_tiles*",
        "/tests_directory/tests/*",
        "/tests_directory/ext-libs/*",
        "/tests_directory/plugin/ui/qt/*",
        # "/tests_directory/vtr_plugin.py",  # todo: remove from here when tests exist
    ])
    cov.start()
    complete_suite = unittest.TestSuite(get_tests())
    print("")
    unittest.TextTestRunner(verbosity=3, stream=sys.stdout).run(complete_suite)
    print("")
    cov.stop()
    cov.save()
    cov.html_report(directory="/tests_directory/coverage")
    cov.xml_report(outfile="/tests_directory/coverage/coverage_report.xml")
    print(cov.report())
Exemplo n.º 8
0
def run_all():
    suite = unittest.TestSuite()
    # OQ_CSV_TO_LAYER_TYPES
    suite.addTest(unittest.makeSuite(LoadAggRiskTestCase, 'test'))
    suite.addTest(unittest.makeSuite(LoadAggLossesStatsTestCase, 'test'))
    suite.addTest(unittest.makeSuite(LoadDmgByEventTestCase, 'test'))
    suite.addTest(unittest.makeSuite(LoadEventsTestCase, 'test'))
    suite.addTest(unittest.makeSuite(LoadAggLossTableTestCase, 'test'))
    suite.addTest(unittest.makeSuite(LoadRealizationsTestCase, 'test'))
    # OQ_EXTRACT_TO_LAYER_TYPES
    suite.addTest(unittest.makeSuite(LoadAssetRiskTestCase, 'test'))
    # NOTE: testing recovery curves starting from damages-rlzs
    suite.addTest(unittest.makeSuite(LoadDamagesRlzsTestCase, 'test'))
    suite.addTest(unittest.makeSuite(LoadAvgLossesRlzsTestCase, 'test'))
    suite.addTest(unittest.makeSuite(LoadAvgLossesStatsTestCase, 'test'))
    suite.addTest(unittest.makeSuite(LoadGmfDataTestCase, 'test'))
    suite.addTest(unittest.makeSuite(LoadHcurvesTestCase, 'test'))
    suite.addTest(unittest.makeSuite(LoadHmapsTestCase, 'test'))
    suite.addTest(unittest.makeSuite(LoadRupturesTestCase, 'test'))
    suite.addTest(unittest.makeSuite(LoadUhsTestCase, 'test'))
    suite.addTest(unittest.makeSuite(LoadDisaggTestCase, 'test'))
    # OQ_ZIPPED_TYPES
    suite.addTest(unittest.makeSuite(LoadInputTestCase, 'test'))
    # OQ_RST_TYPES
    suite.addTest(unittest.makeSuite(LoadFullReportTestCase, 'test'))
    # OQ_EXTRACT_TO_VIEW_TYPES
    suite.addTest(unittest.makeSuite(LoadAggCurvesRlzsTestCase, 'test'))
    suite.addTest(unittest.makeSuite(LoadAggCurvesStatsTestCase, 'test'))
    suite.addTest(unittest.makeSuite(LoadDamagesRlzsAggrTestCase, 'test'))
    suite.addTest(unittest.makeSuite(LoadAvgLossesRlzsAggrTestCase, 'test'))
    suite.addTest(unittest.makeSuite(LoadAvgLossesStatsAggrTestCase, 'test'))

    # Other tests and checks
    suite.addTest(unittest.makeSuite(RunCalculationTestCase, 'test'))
    suite.addTest(
        unittest.makeSuite(AllLoadableOutputsFoundInDemosTestCase, 'test'))
    suite.addTest(unittest.makeSuite(AllLoadersAreImplementedTestCase, 'test'))
    unittest.TextTestRunner(verbosity=3, stream=sys.stdout).run(suite)
Exemplo n.º 9
0
def runSuite(module, tests):
    """This allows for a list of test names to be selectively run.
    Also, ensures unittest verbose output comes at end, after debug output"""
    loader = unittest.defaultTestLoader
    if 'PAL_SUITE' in os.environ:
        if tests:
            suite = loader.loadTestsFromNames(tests, module)
        else:
            raise Exception(
                "\n\n####__ 'PAL_SUITE' set, but no tests specified __####\n")
    else:
        suite = loader.loadTestsFromModule(module)
    verb = 2 if 'PAL_VERBOSE' in os.environ else 0

    out = StringIO.StringIO()
    res = unittest.TextTestRunner(stream=out, verbosity=verb).run(suite)
    if verb:
        print '\nIndividual test summary:'
    print '\n' + out.getvalue()
    out.close()

    if PALREPORTS:
        teststamp = 'PAL Test Report: ' + \
                    datetime.datetime.now().strftime('%Y-%m-%d %X')
        report = '<html><head><title>{0}</title></head><body>'.format(
            teststamp)
        report += '\n<h2>Failed Tests: {0}</h2>'.format(len(PALREPORTS))
        for k, v in PALREPORTS.iteritems():
            report += '\n<h3>{0}</h3>\n{1}'.format(k, v)
        report += '</body></html>'

        tmp = tempfile.NamedTemporaryFile(suffix=".html", delete=False)
        tmp.write(report)
        tmp.close()
        openInBrowserTab('file://' + tmp.name)

    return res
Exemplo n.º 10
0
def run_all():
    """Default function that is called by the runner if nothing else is specified"""
    suite = unittest.TestSuite()
    suite.addTests(unittest.makeSuite(TestGeometries, 'test'))
    unittest.TextTestRunner(verbosity=3, stream=sys.stdout).run(suite)
Exemplo n.º 11
0
def _make_runner(tests=[]):
    suite = unittest.TestSuite()
    for t in tests:
        suite.addTest(TestTestRunner(t))
    runner = unittest.TextTestRunner(verbosity=2)
    return runner.run(suite)
Exemplo n.º 12
0
def run_all(filterString=None):
    """Default function that is called by the runner if nothing else is specified"""
    filterString = 'test_' if filterString is None else filterString
    suite = unittest.TestSuite()
    suite.addTests(unittest.makeSuite(ModelTester, filterString))
    unittest.TextTestRunner(verbosity=3, stream=sys.stdout).run(suite)
def run_all():
    unittest.TextTestRunner(verbosity=3, stream=sys.stdout).run(suite())
Exemplo n.º 14
0
def run_all():
    unittest.TextTestRunner(verbosity=3,
                            stream=sys.stdout).run(integrationTests())
    unittest.TextTestRunner(verbosity=3, stream=sys.stdout).run(unitTests())
Exemplo n.º 15
0
def run_all():
    _suite = unittest.TestSuite()
    _suite.addTest(SettingsUnitSuite())
    unittest.TextTestRunner(verbosity=3, stream=sys.stdout).run(_suite)
        # params['Test']['test string'] ='test'

        WRITER_REGISTRY.saveParamsToProject(params)
        restored_params = WRITER_REGISTRY.readParamsFromProject()
        self.assertEqual(restored_params, params)

    def test06_SaveRestoreWriterFromProject(self):
        """Test saving and restoring writer state to project"""

        writer = LeafletWriter()
        writer.params = getDefaultParams()
        # change some parameters
        writer.params['Appearance']['Add layers list'] = 'Collapsed'
        writer.params['Data export']['Minify GeoJSON files'] = False
        writer.params['Data export']['Precision'] = '4'
        writer.params['Data export']['Mapping library location'] = 'CDN'
        writer.params['Appearance']['Base layer'] = ['a', 'b', 'c']

        WRITER_REGISTRY.saveWriterToProject(writer)

        new_writer = WRITER_REGISTRY.createWriterFromProject()
        self.assertTrue(isinstance(new_writer, LeafletWriter))
        self.assertEqual(new_writer.params, writer.params)


if __name__ == "__main__":
    suite = unittest.TestSuite()
    suite.addTests(unittest.makeSuite(qgis2web_writerRegistryTest))
    runner = unittest.TextTestRunner(verbosity=2)
    runner.run(suite)
Exemplo n.º 17
0
def run_all():
    """Default function that is called by the runner if nothing else is specified"""
    suite = unittest.TestSuite()
    suite.addTests(unittest.makeSuite(EnvironmentSetterAlgorithmsTest, 'test'))
    unittest.TextTestRunner(verbosity=3, stream=sys.stdout).run(suite)
Exemplo n.º 18
0
def run_all():
    _suite = unittest.TestSuite()
    _suite.addTest(CalculateLDNIntegrationSuite())
    unittest.TextTestRunner(verbosity=3, stream=sys.stdout).run(_suite)