def test_cmdline():
    # start script in order to build the command line parser
    global ORIGINAL_START
    if ORIGINAL_START is None:
        ORIGINAL_START = E.Start

    # read the first two columns
    map_option2action = IOTools.readMap(
        IOTools.openFile(FILENAME_OPTIONLIST),
        columns=(0, 1),
        has_header=True)

    files = []
    for label, expression in EXPRESSIONS:
        f = glob.glob(expression)
        files.extend(sorted(f))

    files = filterFiles(files)

    # make sure to use the current working directory as
    # primary lookup.
    sys.path.insert(0, ".")

    # files = [
    #    'scripts/check_db.py',
    #    'scripts/cgat_build_report_page.py']

    for f in files:
        if os.path.isdir(f):
            continue
        if os.path.basename(f) in EXCLUDE:
            continue

        script_name = os.path.abspath(f)
        pyxfile = (os.path.join(os.path.dirname(f), "_") +
                   os.path.basename(f) + "x")

        failTest.description = script_name
        # check if script contains getopt
        with IOTools.openFile(script_name) as inf:
            if "getopt" in inf.read():
                yield (failTest,
                       "script uses getopt directly: %s" % script_name)
                continue

        module, modulename = loadScript(script_name)
        if module is None:
            yield (failTest,
                   "module could not be imported: %s\n" % script_name)
            continue
        E.Start = LocalStart

        try:
            module.main(argv=["--help"])
        except AttributeError:
            yield (failTest,
                   "no main method in %s\n" % script_name)
            ok_(False, "no main method in %s" % script_name)
        except SystemExit:
            yield (failTest,
                   "script does not use E.Start() %s\n" % script_name)
        except DummyError:
            pass

        for option in PARSER.option_list:
            # ignore options added by optparse
            if option.dest is None:
                continue

            optstring = option.get_opt_string()
            if optstring.startswith("--"):
                optstring = optstring[2:]

            check_option.description = script_name + ":" + optstring

            yield(check_option, optstring, os.path.abspath(f),
                  map_option2action)

        # clear up
        del sys.modules[modulename]

        # scripts with pyximport need special handling.
        #
        # Multiple imports of pyximport seems to create
        # some confusion - here, clear up sys.meta_path after
        # each script
        if os.path.exists(pyxfile):
            sys.meta_path = []
Description of a protorpc.remote.Service in API format.
dataset/ETHPy150Open CGATOxford/cgat/tests/test_commandline.py/test_cmdline--crossover with--dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/ext/endpoints/api_config.py/ApiConfigGenerator.pretty_print_config_to_json