コード例 #1
0
ファイル: run_tests.py プロジェクト: whaozl/ibeis
def run_tests():
    """
        >>> from ibeis.tests.run_tests import *  # NOQA

    """

    # DONT USE THESE FLAGS
    #print('--testall and --testslow give you more tests')
    # starts logging for tests
    import ibeis

    ibeis._preload()
    # Build module list and run tests
    import sys
    ensure_testing_data()
    if False:
        ut.change_term_title('RUN IBEIS TESTS')
    exclude_doctests_fnames = set([
        '_autogen_explicit_controller',
        'template_definitions.py',
        'autogen_test_script.py',
    ])
    exclude_dirs = [
        '_broken',
        'old',
        'tests',
        'timeits',
        '_scripts',
        '_timeits',
        '_doc',
        'notebook',
    ]
    if ut.in_pyinstaller_package():
        from os.path import dirname
        dpath_list = [dirname(ibeis.__file__)]
        # Run tests for installer
        doctest_modname_list_ = [
            'ibeis.ibsfuncs',
            'ibeis.viz.interact.interact_qres2',
            'ibeis.viz.interact.interact_matches',
            'ibeis.viz.interact.interact_annotations2',
            'ibeis.viz.interact.interact_name',
            'ibeis.viz.interact.interact_query_decision',
            'ibeis.viz.interact.interact_chip',
            'ibeis.viz.interact.interact_qres',
            'ibeis.algo.Config',
            'ibeis.algo.hots._pipeline_helpers',
            'ibeis.algo.hots.name_scoring',
            'ibeis.algo.hots.devcases',
            'ibeis.algo.hots.neighbor_index',
            'ibeis.algo.hots.automated_helpers',
            'ibeis.algo.hots.hots_query_result',
            'ibeis.algo.hots.automated_oracle',
            'ibeis.algo.hots.nn_weights',
            'ibeis.algo.hots.pipeline',
            'ibeis.algo.hots.automated_params',
            'ibeis.algo.hots.vsone_pipeline',
            'ibeis.algo.hots.automatch_suggestor',
            'ibeis.algo.hots.score_normalization',
            'ibeis.algo.hots.query_request',
            'ibeis.algo.hots.chip_match',
            'ibeis.algo.hots.multi_index',
            'ibeis.algo.hots.qt_inc_automatch',
            'ibeis.algo.hots.query_params',
            'ibeis.algo.hots.precision_recall',
            'ibeis.algo.hots.hstypes',
            'ibeis.algo.hots.match_chips4',
            'ibeis.algo.hots.distinctiveness_normalizer',
            'ibeis.algo.hots.automated_matcher',
            'ibeis.algo.hots.special_query',
            'ibeis.algo.hots.scoring',
            'ibeis.algo.preproc.preproc_annot',
            'ibeis.algo.preproc.preproc_imageset',
            'ibeis.algo.preproc.preproc_image',
            'ibeis.algo.preproc.preproc_residual',
            'ibeis.algo.detect.grabmodels',
            'ibeis.control.manual_annot_funcs',
            'ibeis.control.manual_chip_funcs',
            'ibeis.control.manual_species_funcs',
            'ibeis.control.manual_ibeiscontrol_funcs',
            'ibeis.control._autogen_party_funcs',
            'ibeis.control.manual_garelate_funcs',
            'ibeis.control.manual_name_funcs',
            'ibeis.control._sql_helpers',
            'ibeis.control.manual_wildbook_funcs',
            'ibeis.control.controller_inject',
            'ibeis.control.manual_lblimage_funcs',
            'ibeis.control.IBEISControl',
            'ibeis.control._autogen_featweight_funcs',
            'ibeis.control.manual_imageset_funcs',
            'ibeis.control.manual_feat_funcs',
            'ibeis.control.manual_gsgrelate_funcs',
            'ibeis.control._autogen_annotmatch_funcs',
            'ibeis.control.manual_meta_funcs',
            'ibeis.control.manual_lblannot_funcs',
            'ibeis.control.DB_SCHEMA',
            'ibeis.control.manual_lbltype_funcs',
            'ibeis.control.SQLDatabaseControl',
            'ibeis.control.manual_image_funcs',
            'ibeis.control.manual_annotgroup_funcs',
            'ibeis.control.DBCACHE_SCHEMA',
            'ibeis.init.main_helpers',
            'ibeis.init.sysres',
            'ibeis.gui.clock_offset_gui',
            'ibeis.dbio.export_subset',
            'ibeis.dbio.export_hsdb',
            'ibeis.dbio.ingest_database',
        ]
    else:
        dpath_list = ['ibeis']
        doctest_modname_list_ = ut.find_doctestable_modnames(
            dpath_list, exclude_doctests_fnames, exclude_dirs)

    exclude_doctest_pattern = ut.get_argval(
        ('--exclude-doctest-patterns', '--x'), type_=list, default=[])
    if exclude_doctest_pattern is not None:
        import re
        is_ok = [
            all([
                re.search(pat, name) is None for pat in exclude_doctest_pattern
            ]) for name in doctest_modname_list_
        ]
        doctest_modname_list = ut.compress(doctest_modname_list_, is_ok)
    else:
        doctest_modname_list = doctest_modname_list_

    doctest_modname_list2 = []
    for modname in doctest_modname_list:
        try:
            exec('import ' + modname, globals(), locals())
        except ImportError as ex:
            ut.printex(ex, iswarning=True)
            if not ut.in_pyinstaller_package():
                raise
        else:
            doctest_modname_list2.append(modname)

    module_list = [sys.modules[name] for name in doctest_modname_list2]

    nPass, nTotal, failed_cmd_list = ut.doctest_module_list(module_list)
    if nPass != nTotal:
        return 1
    else:
        return 0
コード例 #2
0
ファイル: run_tests.py プロジェクト: Erotemic/vtool
def run_tests():
    # Build module list and run tests
    import sys

    exclude_doctests_fnames = set([])
    exclude_dirs = ["_broken", "old", "tests", "timeits", "_scripts", "_timeits", "_doc", "notebook"]
    import vtool as vt
    from os.path import dirname

    # dpath_list = ['vtool']
    if ut.in_pyinstaller_package():
        # HACK, find_doctestable_modnames does not work in pyinstaller
        """
        import utool as ut
        import vtool as vt
        dpath_list = [dirname(vt.__file__)]
        doctest_modname_list = ut.find_doctestable_modnames(
            dpath_list, exclude_doctests_fnames, exclude_dirs)
        print(ut.indent('doctest_modname_list = ' + ut.list_str(doctest_modname_list), ' ' * 8))

        """
        doctest_modname_list = [
            "vtool.spatial_verification",
            "vtool.constrained_matching",
            "vtool.coverage_kpts",
            "vtool.image",
            "vtool.histogram",
            "vtool.chip",
            "vtool.distance",
            "vtool.coverage_grid",
            "vtool.linalg",
            "vtool.geometry",
            "vtool.other",
            "vtool.math",
            "vtool.score_normalization",
            "vtool.test_constrained_matching",
            "vtool.keypoint",
            "vtool.sver_c_wrapper",
            "vtool.quality_classifier",
            "vtool.features",
            "vtool.nearest_neighbors",
            "vtool.segmentation",
            "vtool.exif",
            "vtool.patch",
            "vtool.confusion",
            "vtool.blend",
            "vtool.clustering2",
            "vtool.matching",
        ]
    else:
        dpath_list = [dirname(vt.__file__)]
        doctest_modname_list = ut.find_doctestable_modnames(dpath_list, exclude_doctests_fnames, exclude_dirs)

    modname_list2 = []
    for modname in doctest_modname_list:
        try:
            exec("import " + modname, globals(), locals())
        except ImportError as ex:
            ut.printex(ex)
            if not ut.in_pyinstaller_package():
                raise
        else:
            modname_list2.append(modname)

    module_list = [sys.modules[name] for name in modname_list2]
    nPass, nTotal, failed_cmd_list = ut.doctest_module_list(module_list)
    if nPass != nTotal:
        return 1
    else:
        return 0
コード例 #3
0
def run_tests():
    """
        >>> from ibeis.tests.run_tests import *  # NOQA
    """
    # starts logging for tests
    import ibeis

    ibeis._preload()
    # Build module list and run tests
    import sys
    if True:
        ensure_testing_data()

    if ut.in_pyinstaller_package():
        # Run tests for installer
        doctest_modname_list_ = static_doctest_modnames()
    else:
        doctest_modname_list_ = dynamic_doctest_modnames()

    exclude_doctest_pattern = ut.get_argval(
        ('--exclude-doctest-patterns', '--x'), type_=list, default=[])
    if exclude_doctest_pattern is not None:
        import re
        is_ok = [
            all([
                re.search(pat, name) is None for pat in exclude_doctest_pattern
            ]) for name in doctest_modname_list_
        ]
        doctest_modname_list = ut.compress(doctest_modname_list_, is_ok)
    else:
        doctest_modname_list = doctest_modname_list_

    coverage = ut.get_argflag((
        '--coverage',
        '--cov',
    ))
    if coverage:
        import coverage
        cov = coverage.Coverage(source=doctest_modname_list)
        cov.start()
        print('Starting coverage')

        exclude_lines = [
            'pragma: no cover',
            'def __repr__',
            'if self.debug:',
            'if settings.DEBUG',
            'raise AssertionError',
            'raise NotImplementedError',
            'if 0:',
            'if ut.VERBOSE',
            'if _debug:',
            'if __name__ == .__main__.:',
            'print(.*)',
        ]
        for line in exclude_lines:
            cov.exclude(line)

    doctest_modname_list2 = []

    try:
        import guitool  # NOQA
    except ImportError:
        HAVE_GUI = False
    else:
        HAVE_GUI = True

    # Remove gui things if possible
    import re
    if not HAVE_GUI:
        doctest_modname_list = [
            modname for modname in doctest_modname_list_
            if not re.search('\\bgui\\b', modname)
            and not re.search('\\bviz\\b', modname)
        ]

    for modname in doctest_modname_list:
        try:
            exec('import ' + modname, globals(), locals())
        except ImportError as ex:
            ut.printex(ex, iswarning=True)
            # import parse
            # if not HAVE_GUI:
            #     try:
            #         parsed = parse.parse('No module named {}', str(ex))
            #         if parsed is None:
            #             parsed = parse.parse('cannot import name {}', str(ex))
            #         if parsed is not None:
            #             if parsed[0].endswith('_gui'):
            #                 print('skipping gui module %r' % (parsed[0],))
            #                 continue
            #             if parsed[0].startswith('viz_'):
            #                 print('skipping viz module %r' % (parsed[0],))
            #                 continue
            #             if parsed[0].startswith('interact_'):
            #                 print('skipping interact module %r' % (parsed[0],))
            #                 continue
            #             # if parsed[0] in ['sip']:
            #             #     print('skipping Qt module %r' % (parsed[0],))
            #             #     continue
            #     except:
            #         pass
            if not ut.in_pyinstaller_package():
                raise
        else:
            doctest_modname_list2.append(modname)

    module_list = [sys.modules[name] for name in doctest_modname_list2]

    # Write to py.test / nose format
    if ut.get_argflag('--tonose'):
        convert_tests_from_ibeis_to_nose(module_list)
        return 0

    nPass, nTotal, failed_cmd_list = ut.doctest_module_list(module_list)

    if coverage:
        print('Stoping coverage')
        cov.stop()
        print('Saving coverage')
        cov.save()
        print('Generating coverage html report')
        cov.html_report()

    if nPass != nTotal:
        return 1
    else:
        return 0
コード例 #4
0
ファイル: run_tests.py プロジェクト: Erotemic/utool
def run_tests():
    # Build module list and run tests
    import sys
    exclude_doctests_fnames = set(['__init__.py'])

    exclude_dirs = [
        '_broken',
        'old',
        'tests',
        'timeits',
        '_scripts',
        '_timeits',
        '_doc',
        'notebook',
    ]
    from os.path import dirname
    #dpath_list = ['vtool']
    if ut.in_pyinstaller_package():
        # HACK, find_doctestable_modnames does not work in pyinstaller
        """
        import utool as ut
        dpath_list = [dirname(ut.__file__)]
        doctest_modname_list = ut.find_doctestable_modnames(
            dpath_list, exclude_doctests_fnames, exclude_dirs)
        print(ut.indent('doctest_modname_list = ' + ut.repr4(doctest_modname_list), ' ' * 8))

        """
        doctest_modname_list = [
            'utool.util_class',
            'utool.util_distances',
            'utool.util_progress',
            'utool.util_cache',
            'utool.Preferences',
            'utool.util_list',
            'utool',
            'utool.util_inspect',
            'utool.util_dict',
            'utool.util_dev',
            'utool.util_time',
            'utool.util_type',
            'utool.util_csv',
            'utool.util_iter',
            'utool.util_print',
            'utool.util_arg',
            'utool.util_logging',
            'utool.util_import',
            'utool.util_parallel',
            'utool.util_cplat',
            'utool.util_str',
            'utool.util_gridsearch',
            'utool.util_numpy',
            'utool.util_dbg',
            'utool.util_io',
            'utool.util_decor',
            'utool.util_grabdata',
            'utool.util_path',
            'utool.util_git',
            'utool.util_inject',
            'utool.util_regex',
            'utool.util_assert',
            'utool.util_latex',
            'utool.util_tests',
            'utool.util_config',
            'utool.util_autogen',
            'utool.util_hash',
            'utool.util_alg',
            'utool.util_resources',
            'utool._internal.meta_util_iter',
        ]
    else:
        #dpath_list = ['utool']
        dpath_list = [dirname(ut.__file__)]
        doctest_modname_list = ut.find_doctestable_modnames(
            dpath_list, exclude_doctests_fnames, exclude_dirs)
    # Finding weird error
    # util cache and util inspect
    #doctest_modname_list = (doctest_modname_list[4:5] + doctest_modname_list[17:18])
    #doctest_modname_list = doctest_modname_list[17:18]

    modname_list2 = []
    for modname in doctest_modname_list:
        try:
            exec('import ' + modname, globals(), locals())
        except ImportError as ex:
            ut.printex(ex)
            if not ut.in_pyinstaller_package():
                raise
        else:
            modname_list2.append(modname)

    module_list = [sys.modules[name] for name in modname_list2]

    # Write to py.test / nose format
    if ut.get_argflag('--tonose'):
        convert_tests_from_utool_to_nose(module_list)
        return 0

    nPass, nTotal, failed_cmd_list = ut.doctest_module_list(module_list)
    if nPass != nTotal:
        return 1
    else:
        return 0
コード例 #5
0
ファイル: run_tests.py プロジェクト: SU-ECE-18-7/vtool
def run_tests():
    # Build module list and run tests
    import sys
    exclude_doctests_fnames = set([])
    exclude_dirs = [
        '_broken',
        'old',
        'tests',
        'timeits',
        '_scripts',
        '_timeits',
        '_doc',
        'notebook',
    ]
    import vtool as vt
    from os.path import dirname
    #dpath_list = ['vtool']
    if ut.in_pyinstaller_package():
        # HACK, find_doctestable_modnames does not work in pyinstaller
        """
        import utool as ut
        import vtool as vt
        dpath_list = [dirname(vt.__file__)]
        doctest_modname_list = ut.find_doctestable_modnames(
            dpath_list, exclude_doctests_fnames, exclude_dirs)
        print(ut.indent('doctest_modname_list = ' + ut.list_str(doctest_modname_list), ' ' * 8))

        """
        doctest_modname_list = [
            'vtool.spatial_verification',
            'vtool.constrained_matching',
            'vtool.coverage_kpts',
            'vtool.image',
            'vtool.histogram',
            'vtool.chip',
            'vtool.distance',
            'vtool.coverage_grid',
            'vtool.linalg',
            'vtool.geometry',
            'vtool.other',
            'vtool.math',
            'vtool.score_normalization',
            'vtool.test_constrained_matching',
            'vtool.keypoint',
            'vtool.sver_c_wrapper',
            'vtool.quality_classifier',
            'vtool.features',
            'vtool.nearest_neighbors',
            'vtool.segmentation',
            'vtool.exif',
            'vtool.patch',
            'vtool.confusion',
            'vtool.blend',
            'vtool.clustering2',
            'vtool.matching',
        ]
    else:
        dpath_list = [dirname(vt.__file__)]
        doctest_modname_list = ut.find_doctestable_modnames(
            dpath_list, exclude_doctests_fnames, exclude_dirs)

    modname_list2 = []
    for modname in doctest_modname_list:
        try:
            exec('import ' + modname, globals(), locals())
        except ImportError as ex:
            ut.printex(ex)
            if not ut.in_pyinstaller_package():
                raise
        else:
            modname_list2.append(modname)

    module_list = [sys.modules[name] for name in modname_list2]
    nPass, nTotal, failed_cmd_list = ut.doctest_module_list(module_list)
    if nPass != nTotal:
        return 1
    else:
        return 0
コード例 #6
0
def run_tests():
    # Build module list and run tests
    import sys
    exclude_doctests_fnames = set(['__init__.py'])

    exclude_dirs = [
        '_broken',
        'old',
        'tests',
        'timeits',
        '_scripts',
        '_timeits',
        '_doc',
        'notebook',
    ]
    from os.path import dirname
    #dpath_list = ['vtool']
    if ut.in_pyinstaller_package():
        # HACK, find_doctestable_modnames does not work in pyinstaller
        """
        import utool as ut
        dpath_list = [dirname(ut.__file__)]
        doctest_modname_list = ut.find_doctestable_modnames(
            dpath_list, exclude_doctests_fnames, exclude_dirs)
        print(ut.indent('doctest_modname_list = ' + ut.list_str(doctest_modname_list), ' ' * 8))

        """
        doctest_modname_list = [
            'utool.util_class',
            'utool.util_distances',
            'utool.util_progress',
            'utool.util_cache',
            'utool.Preferences',
            'utool.util_list',
            'utool',
            'utool.util_inspect',
            'utool.util_dict',
            'utool.util_dev',
            'utool.util_time',
            'utool.util_type',
            'utool.util_csv',
            'utool.util_iter',
            'utool.util_print',
            'utool.util_arg',
            'utool.util_logging',
            'utool.util_import',
            'utool.util_parallel',
            'utool.util_cplat',
            'utool.util_str',
            'utool.util_gridsearch',
            'utool.util_numpy',
            'utool.util_dbg',
            'utool.util_io',
            'utool.util_decor',
            'utool.util_grabdata',
            'utool.util_path',
            'utool.util_git',
            'utool.util_inject',
            'utool.util_regex',
            'utool.util_assert',
            'utool.util_latex',
            'utool.util_tests',
            'utool.util_config',
            'utool.util_autogen',
            'utool.util_hash',
            'utool.util_alg',
            'utool.util_resources',
            'utool._internal.meta_util_iter',
        ]
    else:
        #dpath_list = ['utool']
        dpath_list = [dirname(ut.__file__)]
        doctest_modname_list = ut.find_doctestable_modnames(
            dpath_list, exclude_doctests_fnames, exclude_dirs)
    # Finding weird error
    # util cache and util inspect
    #doctest_modname_list = (doctest_modname_list[4:5] + doctest_modname_list[17:18])
    #doctest_modname_list = doctest_modname_list[17:18]

    modname_list2 = []
    for modname in doctest_modname_list:
        try:
            exec('import ' + modname, globals(), locals())
        except ImportError as ex:
            ut.printex(ex)
            if not ut.in_pyinstaller_package():
                raise
        else:
            modname_list2.append(modname)

    module_list = [sys.modules[name] for name in modname_list2]

    # Write to py.test / nose format
    if ut.get_argflag('--tonose'):
        convert_tests_from_utool_to_nose(module_list)
        return 0

    nPass, nTotal, failed_cmd_list = ut.doctest_module_list(module_list)
    if nPass != nTotal:
        return 1
    else:
        return 0