Return the string you can pass to nose to run `test`, including argument
    values if the test was made by a test generator.

    Return "Unknown test" if it can't construct a decent path.
554947
def nose_selector(test):
    
    address = test_address(test)
    if address:
        file, module, rest = address

        if module:
            if rest:
                try:
                    return '%s:%s%s' % (module, rest, test.test.arg or '')
                except AttributeError:
                    return '%s:%s' % (module, rest)
            else:
                return module
    return 'Unknown test'
1069424
def getargnames(argspecs, with_unbox=False):
    
    # todo: We can maybe make use of inspect.formatargspec
    args = argspecs.args
    vargs = argspecs.varargs
    try:
        kw = argspecs.keywords
    except AttributeError:
        kw = argspecs.varkw
    try:
        kwonly = argspecs.kwonlyargs
    except AttributeError:
        kwonly = None
    res = []
    if not args is None:
        res.extend(args)
    if not vargs is None:
        res.append('*'+vargs if with_unbox else vargs)
    if not kwonly is None:
        res.extend(kwonly)
    if not kw is None:
        res.append('**'+kw if with_unbox else kw)
    return res
99007
def get_option(name):
    
    d = globals()

    if name in {'get_option', 'set_option'} or name not in d:
        from ..exceptions import PlotnineError
        raise PlotnineError("Unknown option {}".format(name))

    return d[name]
354950
def findTheLost(config_file, configspec_file, skipHidden=True):
    
    # do some sanity checking, but don't (yet) make this a serious error
    if not os.path.exists(config_file):
        print("ERROR: Config file not found: "+config_file)
        return []
    if not os.path.exists(configspec_file):
        print("ERROR: Configspec file not found: "+configspec_file)
        return []
    tmpObj = configobj.ConfigObj(config_file, configspec=configspec_file)
    simval = configobj.SimpleVal()
    test = tmpObj.validate(simval)
    if test == True:
        return []
    # If we get here, there is a dict returned of {key1: bool, key2: bool}
    # which matches the shape of the config obj.  We need to walk it to
    # find the Falses, since they are the missing pars.
    missing = []
    flattened = configobj.flatten_errors(tmpObj, test)
    # But, before we move on, skip/eliminate any 'hidden' items from our list,
    # since hidden items are really supposed to be missing from the .cfg file.
    if len(flattened) > 0 and skipHidden:
        keepers = []
        for tup in flattened:
            keep = True
            # hidden section
            if len(tup[0])>0 and isHiddenName(tup[0][-1]):
                keep = False
            # hidden par (in a section, or at the top level)
            elif tup[1] is not None and isHiddenName(tup[1]):
                keep = False
            if keep:
                keepers.append(tup)
        flattened = keepers
    flatStr = flattened2str(flattened, missing=True)
    return flatStr
1253233
def get(url)
      begin
        uri = URI.parse(url.strip)
      rescue URI::InvalidURIError
        uri = URI.parse(URI.escape(url.strip))
      end

      # simple hack to read in fixtures instead of url for tests
      fixture = "#{File.dirname(__FILE__)}/../fixtures#{uri.path}"
      File.read(fixture) if File.exist?(fixture)
    end
1074620
def get_argument_parser():
    
    file_mv = cli.file_mv

    desc = 'Find all runs (SRR..) associated with an SRA experiment (SRX...).'

    parser = cli.get_argument_parser(desc=desc)

    parser.add_argument(
        '-e', '--experiment-file', type=str, required=True, metavar=file_mv,
        help='File with SRA experiment IDs (starting with "SRX").'
    )

    parser.add_argument(
        '-o', '--output-file', type=str, required=True, metavar=file_mv,
        help='The output file.'
    )

    cli.add_reporting_args(parser)

    return parser
94672
def get_string(self, input_string):
        

        if input_string in ('--input', '--outname', '--framework'):

            # was the flag set?
            try:
                index = self.args.index(input_string) + 1
            except ValueError:
                # it wasn't, so if it's required, exit
                if input_string in self.required:
                    print("\n {flag} is required".format(input_string))
                    print_short_help()
                    sys.exit(1)
                # it wasn't, if its optional, return the default
                else:
                    return None

                    # the flag was set, so check if a value was set, otherwise exit
            try:
                if self.args[index] in self.flags:
                    print("\n {flag} was set but a value was not specified".format(flag=input_string))
                    print_short_help()
                    sys.exit(1)
            except IndexError:
                print("\n {flag} was set but a value was not specified".format(input_string))
                print_short_help()
                sys.exit(1)

            # a value was set, so check and assign the appropriate value or exit
            if input_string == '--input':
                return os.path.abspath(self.args[index])
            elif input_string == '--outname':
                return format(self.args[index])
989086
def get_id(test):
    
    test_id = test.id()
    module_length = len(test.test.__module__)
    return test_id[:module_length] + ":" + test_id[module_length + 1:]
1294772
def run(self, path_or_tests, dot_env_path=None, mapping=None):
        
        if validator.is_testcase_path(path_or_tests):
            return self.run_path(path_or_tests, dot_env_path, mapping)
        elif validator.is_testcases(path_or_tests):
            return self.run_tests(path_or_tests)
        else:
            raise exceptions.ParamsError("Invalid testcase path or testcases: {}".format(path_or_tests))
86416
def find_path(self, test_function=None, on_targets=False):
        
        assert self.has_referential_domain(), "need context set"

        if not test_function:
            test_function = lambda x, y: True
           
        def find_path_inner(part, prefix):
            name, structure = part
            if test_function(name, structure):
                yield prefix + [name]
            if isinstance(structure, DictCell):
                for sub_structure in structure:
                    for prefix2 in find_path_inner(sub_structure,\
                            prefix[:] + [name]):
                        yield prefix2

        prefix = []
        if on_targets:
            # apply search to the first target
            results = []
            for _, instance in self.iter_singleton_referents():
                for part in instance:
                    for entry in find_path_inner(part, prefix[:]):
                        results.append(['target'] + entry)
                while results:
                    yield results.pop()
                break # only use first instance
        else:
            # apply search to self
            for part in self:
                for entry in find_path_inner(part, prefix[:]):
                    yield entry
203777
function checkForUnknownArguments (yargs, argv) {
    var aliasLookup = {};
    var descriptions = yargs.getUsageInstance().getDescriptions();
    var demanded = yargs.getDemanded();
    var unknown = [];

    Object.keys(yargs.parsed.aliases || {}).forEach(function (key) {
        yargs.parsed.aliases[key].forEach(function (alias) {
            aliasLookup[alias] = key;
        });
    });

    Object.keys(argv).forEach(function (key) {
        if (key !== '$0' && key !== '_' && key !== 'params' &&
            !descriptions.hasOwnProperty(key) &&
            !demanded.hasOwnProperty(key) &&
            !aliasLookup.hasOwnProperty('no-' + key) &&
            !aliasLookup.hasOwnProperty(key)) {
                unknown.push(key);
        }
    });

    if (unknown.length === 1) {
        throw Cli.usageError('Unknown argument: ' + unknown[0]);
    } else if (unknown.length > 1) {
        throw Cli.usageError('Unknown arguments: ' + unknown.join(', '));
    }
}
1166048
def guess_format(path):
    """"""
    for fmt in formats:
        if fmt.verify(path):
            return fmt.__name__
    else:
        msg = "Undefined file format: '{}'".format(path)
        raise UnknownFileFormatError(msg)
668962
def string_is_url(test_str):
    
    parsed = urlparse.urlparse(test_str)
    return parsed.scheme is not None and parsed.scheme != ''
692301
def detect_version_str(self):
        
        help_text = run_matlab_cmd("help('{}')".format(self.test_func))
        if not help_text:
            raise ArcanaRequirementNotFoundError(
                "Did not find test function '{}' for {}"
                .format(self.test_func, self))
        return self.parse_help_text(help_text)
102089
def run_nose(self, params):
        
        thread.set_index(params.thread_index)
        log.debug("[%s] Starting nose iterations: %s", params.worker_index, params)
        assert isinstance(params.tests, list)
        # argv.extend(['--with-apiritif', '--nocapture', '--exe', '--nologcapture'])

        end_time = self.params.ramp_up + self.params.hold_for
        end_time += time.time() if end_time else 0
        time.sleep(params.delay)

        plugin = ApiritifPlugin(self._writer)
        self._writer.concurrency += 1

        config = Config(env=os.environ, files=all_config_files(), plugins=DefaultPluginManager())
        config.plugins.addPlugins(extraplugins=[plugin])
        config.testNames = params.tests
        config.verbosity = 3 if params.verbose else 0
        if params.verbose:
            config.stream = open(os.devnull, "w")  # FIXME: use "with", allow writing to file/log

        iteration = 0
        try:
            while True:
                log.debug("Starting iteration:: index=%d,start_time=%.3f", iteration, time.time())
                thread.set_iteration(iteration)
                ApiritifTestProgram(config=config)
                log.debug("Finishing iteration:: index=%d,end_time=%.3f", iteration, time.time())

                iteration += 1

                # reasons to stop
                if plugin.stop_reason:
                    log.debug("[%s] finished prematurely: %s", params.worker_index, plugin.stop_reason)
                elif iteration >= params.iterations:
                    log.debug("[%s] iteration limit reached: %s", params.worker_index, params.iterations)
                elif 0 < end_time <= time.time():
                    log.debug("[%s] duration limit reached: %s", params.worker_index, params.hold_for)
                else:
                    continue  # continue if no one is faced

                break
        finally:
            self._writer.concurrency -= 1

            if params.verbose:
                config.stream.close()
449917
def _get_argname_value(self, argname):
        '''
        
        '''
        # Let's see if there's a private function to get the value
        argvalue = getattr(self, '__get_{0}__'.format(argname), None)
        if argvalue is not None and callable(argvalue):
            argvalue = argvalue()
        if argvalue is None:
            # Let's see if the value is defined as a public class variable
            argvalue = getattr(self, argname, None)
        if argvalue is None:
            # Let's see if it's defined as a private class variable
            argvalue = getattr(self, '__{0}__'.format(argname), None)
        if argvalue is None:
            # Let's look for it in the extra dictionary
            argvalue = self.extra.get(argname, None)
        return argvalue
320591
def run(self, test):
        ""
        # These parts of Nose's pluggability are baked into
        # nose.core.TextTestRunner. Reproduce them:
        wrapper = self.config.plugins.prepareTest(test)
        if wrapper is not None:
            test = wrapper
        wrapped = self.config.plugins.setOutputStream(self.stream)
        if wrapped is not None:
            self.stream = wrapped

        result = self._makeResult()
        startTime = time()
        try:
            test(result)
        except KeyboardInterrupt:
            # we need to ignore these exception to not
            # show traceback when user intentionally
            # interrupted test suite execution, and
            # to output some reasonable results on
            # already passed and failed tests.
            pass
        stopTime = time()

        # We don't care to hear about errors again at the end; we take care of
        # that in result.addError(), while the tests run.
        # result.printErrors()
        #
        # However, we do need to call this one useful line from
        # nose.result.TextTestResult's implementation of printErrors() to make
        # sure other plugins get a chance to report:
        self.config.plugins.report(self.stream)

        result.printSummary(startTime, stopTime)
        self.config.plugins.finalize(result)
        return result