当前位置: 首页>>代码示例>>Python>>正文


Python util.tolist函数代码示例

本文整理汇总了Python中nose.util.tolist函数的典型用法代码示例。如果您正苦于以下问题:Python tolist函数的具体用法?Python tolist怎么用?Python tolist使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了tolist函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: configure

    def configure(self, argv=None, doc=None):
        """Configure the nose running environment. Execute configure before
        collecting tests with nose.TestCollector to enable output capture and
        other features.
        """
        env = self.env
        if argv is None:
            argv = sys.argv

        cfg_files = getattr(self, 'files', [])
        options, args = self._parseArgs(argv, cfg_files)
        # If -c --config has been specified on command line,
        # load those config files and reparse
        if getattr(options, 'files', []):
            options, args = self._parseArgs(argv, options.files)

        self.options = options
        if args:
            self.testNames = args
        if options.testNames is not None:
            self.testNames.extend(tolist(options.testNames))

        # `where` is an append action, so it can't have a default value 
        # in the parser, or that default will always be in the list
        if not options.where:
            options.where = env.get('NOSE_WHERE', None)

        # include and exclude also
        if not options.include:
            options.include = env.get('NOSE_INCLUDE', [])
        if not options.exclude:
            options.exclude = env.get('NOSE_EXCLUDE', [])

        self.addPaths = options.addPaths
        self.stopOnError = options.stopOnError
        self.verbosity = options.verbosity
        self.includeExe = options.includeExe
        self.debug = options.debug
        self.debugLog = options.debugLog
        self.loggingConfig = options.loggingConfig
        self.configureLogging()

        if options.where is not None:
            self.configureWhere(options.where)
        
        if options.testMatch:
            self.testMatch = re.compile(options.testMatch)
                
        if options.include:
            self.include = map(re.compile, tolist(options.include))
            log.info("Including tests matching %s", options.include)

        if options.exclude:
            self.exclude = map(re.compile, tolist(options.exclude))
            log.info("Excluding tests matching %s", options.exclude)

        # When listing plugins we don't want to run them
        if not options.showPlugins:
            self.plugins.configure(options, self)
            self.plugins.begin()
开发者ID:adrianpike,项目名称:wwscc,代码行数:60,代码来源:config.py

示例2: configure

    def configure(self, options, config):
        """Configure the plugin and system, based on selected options.

        attr and eval_attr may each be lists.

        self.attribs will be a list of lists of tuples. In that list, each
        list is a group of attributes, all of which must match for the rule to
        match.
        """
        self.attribs = []

        # handle python eval-expression parameter
        if compat_24 and options.eval_attr:
            eval_attr = tolist(options.eval_attr)
            for attr in eval_attr:
                # "<python expression>"
                # -> eval(expr) in attribute context must be True
                def eval_in_context(expr, obj, cls):
                    return eval(expr, None, ContextHelper(obj, cls))

                self.attribs.append([(attr, eval_in_context)])

        # attribute requirements are a comma separated list of
        # 'key=value' pairs
        if options.attr:
            std_attr = tolist(options.attr)
            for attr in std_attr:
                # all attributes within an attribute group must match
                attr_group = []
                for attrib in attr.strip().split(","):
                    # don't die on trailing comma
                    if not attrib:
                        continue
                    items = attrib.split("=", 1)
                    if len(items) > 1:
                        # "name=value"
                        # -> 'str(obj.name) == value' must be True
                        key, value = items
                    else:
                        key = items[0]
                        if key[0] == "!":
                            # "!name"
                            # 'bool(obj.name)' must be False
                            key = key[1:]
                            value = False
                        else:
                            # "name"
                            # -> 'bool(obj.name)' must be True
                            value = True
                    attr_group.append((key, value))
                self.attribs.append(attr_group)
        if self.attribs:
            self.enabled = True
开发者ID:JingzheTian,项目名称:popcorn_maker,代码行数:53,代码来源:attrib.py

示例3: configure

 def configure(self, options, config):
     """
     Configure plugin.
     """
     try:
         self.status.pop('active')
     except KeyError:
         pass
     Plugin.configure(self, options, config)
     if self.enabled:
         try:
             import coverage
         except ImportError:
             log.error("Coverage not available: "
                       "unable to import coverage module")
             self.enabled = False
             return
     self.conf = config
     self.coverErase = options.cover_erase
     self.coverTests = options.cover_tests
     self.coverPackages = []
     if options.cover_packages:
         for pkgs in [tolist(x) for x in options.cover_packages]:
             self.coverPackages.extend(pkgs)
     self.coverInclusive = options.cover_inclusive
     if self.coverPackages:
         log.info("Coverage report will include only packages: %s",
                  self.coverPackages)
     self.coverHtmlDir = None
     if options.cover_html:
         self.coverHtmlDir = options.cover_html_dir
         log.debug('Will put HTML coverage report in %s', self.coverHtmlDir)
     if self.enabled:
         self.status['active'] = True
开发者ID:LucianU,项目名称:kuma-lib,代码行数:34,代码来源:cover.py

示例4: configure

    def configure(self, options, noseconfig):
        """ Call the super and then validate and call the relevant parser for
        the configuration file passed in """
        if not options.testconfig:
            return
        Plugin.configure(self, options, noseconfig)

        self.config = noseconfig
        if not options.capture:
            self.enabled = False
        if options.testconfigformat:
            self.format = options.testconfigformat
            if self.format not in self.valid_loaders.keys():
                raise Exception('%s is not a valid configuration file format' \
                                                                % self.format)

        # Load the configuration file:
        self.valid_loaders[self.format](options.testconfig)

        if options.overrides:
            self.overrides = []
            overrides = tolist(options.overrides)
            for override in overrides:
                keys, val = override.split(":")
                if options.exact:
                    config[keys] = val
                else:                    
                    ns = ''.join(['["%s"]' % i for i in keys.split(".") ])
                    # BUG: Breaks if the config value you're overriding is not
                    # defined in the configuration file already. TBD
                    exec('config%s = "%s"' % (ns, val))
开发者ID:conorfi,项目名称:automation,代码行数:31,代码来源:testconfig.py

示例5: configureWhere

 def configureWhere(self, where):
     """Configure the working directory or directories for the test run.
     """
     from nose.importer import add_path
     self.workingDir = None
     where = tolist(where)
     warned = False
     for path in where:
         if not self.workingDir:
             abs_path = absdir(path)
             if abs_path is None:
                 raise ValueError("Working directory %s not found, or "
                                  "not a directory" % path)
             log.info("Set working dir to %s", abs_path)
             self.workingDir = abs_path
             if self.addPaths and \
                    os.path.exists(os.path.join(abs_path, '__init__.py')):
                 log.info("Working directory %s is a package; "
                          "adding to sys.path" % abs_path)
                 add_path(abs_path)
             continue
         if not warned:
             warn("Use of multiple -w arguments is deprecated and "
                  "support may be removed in a future release. You can "
                  "get the same behavior by passing directories without "
                  "the -w argument on the command line, or by using the "
                  "--tests argument in a configuration file.",
                  DeprecationWarning)
         self.testNames.append(path)
开发者ID:LucianU,项目名称:kuma-lib,代码行数:29,代码来源:config.py

示例6: configure

    def configure(self, options, conf):
        """
        Configure plugin.
        """
        try:
            self.status.pop('active')
        except KeyError:
            pass

        super(DuvetCover, self).configure(options, conf)

        if conf.worker:
            return

        self.enabled = bool(coverage) and bool(git)

        self.conf = conf
        self.options = options

        self.coverPackages = []
        if options.cover_packages:
            if isinstance(options.cover_packages, (list, tuple)):
                cover_packages = options.cover_packages
            else:
                cover_packages = [options.cover_packages]
            for pkgs in [tolist(x) for x in cover_packages]:
                self.coverPackages.extend(pkgs)

        if self.coverPackages:
            log.info("Coverage report will include only packages: %s",
                     self.coverPackages)

        if self.enabled:
            self.status['active'] = True
开发者ID:public,项目名称:python-duvet,代码行数:34,代码来源:nose.py

示例7: wantModuleCoverage

 def wantModuleCoverage(self, name, module):
     if not hasattr(module, '__file__'):
         log.debug("no coverage of %s: no __file__", name)
         return False
     root, ext = os.path.splitext(module.__file__)
     if not ext in ('.py', '.pyc', '.pyo'):
         log.debug("no coverage of %s: not a python file", name)
         return False
     if tolist(self.options.cover_packages):
         for package in self.options.cover_packages:
             if (name.startswith(package)
                 and (self.options.cover_tests
                      or not self.conf.testMatch.search(name))):
                 log.debug("coverage for %s", name)
                 return True
     if name in self.skipModules:
         log.debug("no coverage for %s: loaded before coverage start",
                   name)
         return False
     if self.conf.testMatch.search(name) and not self.options.cover_tests:
         log.debug("no coverage for %s: is a test", name)
         return False
     # accept any package that passed the previous tests, unless
     # coverPackages is on -- in that case, if we wanted this
     # module, we would have already returned True
     return not self.options.cover_packages
开发者ID:UfSoft,项目名称:trac-bitten-extra-nose,代码行数:26,代码来源:plugnose.py

示例8: configure

    def configure(self, options, config):
        plugins.Plugin.configure(self, options, config)
        self.conf = config
        self.tissue_packages = []
        self.tissue_statistics = options.tissue_statistics
        self.tissue_fail_on_error = options.tissue_fail_on_error
        if options.tissue_packages:
            for pkgs in [util.tolist(x) for x in options.tissue_packages]:
                self.tissue_packages.extend(pkgs)
        self.tissue_inclusive = options.tissue_inclusive
        if self.tissue_packages:
            log.info('PEP8 report will include only packages: %s',
                     self.tissue_packages)

        arglist = []
        if options.tissue_repeat:
            arglist.append('--repeat')

        if options.tissue_select:
            arglist.append('--select')
            arglist.append(options.tissue_select)

        if options.tissue_ignore:
            arglist.append('--ignore')
            arglist.append(options.tissue_ignore)

        if options.tissue_show_source:
            arglist.append('--show-source')

        if options.tissue_show_pep8:
            arglist.append('--show-pep8')

        options, paths = pep8.process_options(arglist)
        self.pep8 = pep8.StyleGuide(**options.__dict__)
        self.pep8.init_report(TissueReport)
开发者ID:WoLpH,项目名称:tissue,代码行数:35,代码来源:tissue.py

示例9: configure

 def configure(self, options, config):
     """Configure plugin.
     """
     Plugin.configure(self, options, config)
     self.doctest_result_var = options.doctest_result_var
     self.doctest_tests = options.doctest_tests
     self.extension = tolist(options.doctestExtension)
     self.fixtures = options.doctestFixtures
     self.finder = doctest.DocTestFinder()
     self.optionflags = 0
     if options.doctestOptions:
         flags = ",".join(options.doctestOptions).split(',')
         for flag in flags:
             try:
                 if flag.startswith('+'):
                     self.optionflags |= getattr(doctest, flag[1:])
                 elif flag.startswith('-'):
                     self.optionflags &= ~getattr(doctest, flag[1:])
                 else:
                     raise ValueError(
                         "Must specify doctest options with starting " +
                         "'+' or '-'.  Got %s" % (flag,))
             except AttributeError:
                 raise ValueError("Unknown doctest option %s" %
                                  (flag[1:],))
开发者ID:rupenp,项目名称:python-nlg,代码行数:25,代码来源:doctests.py

示例10: configure

 def configure(self, options, config):
     """Configure plugin.
     """
     Plugin.configure(self, options, config)
     self.doctest_result_var = options.doctest_result_var
     self.doctest_tests = options.doctest_tests
     self.extension = tolist(options.doctestExtension)
     self.fixtures = options.doctestFixtures
     self.finder = doctest.DocTestFinder()
     self.optionflags = 0
     if options.doctestOptions:
         flags = ",".join(options.doctestOptions).split(',')
         for flag in flags:
             if not flag or flag[0] not in '+-':
                 raise ValueError(
                     "Must specify doctest options with starting " +
                     "'+' or '-'.  Got %s" % (flag,))
             mode, option_name = flag[0], flag[1:]
             option_flag = doctest.OPTIONFLAGS_BY_NAME.get(option_name)
             if not option_flag:
                 raise ValueError("Unknown doctest option %s" %
                                  (option_name,))
             if mode == '+':
                 self.optionflags |= option_flag
             elif mode == '-':
                 self.optionflags &= ~option_flag
开发者ID:AlexSnet,项目名称:oneline,代码行数:26,代码来源:doctests.py

示例11: options

 def options(self, parser, env=os.environ):
     # print "Options for nose plugin:", self.name # dbg
     Plugin.options(self, parser, env)
     parser.add_option(
         "--ipdoctest-tests",
         action="store_true",
         dest="ipdoctest_tests",
         default=env.get("NOSE_IPDOCTEST_TESTS", True),
         help="Also look for doctests in test modules. "
         "Note that classes, methods and functions should "
         "have either doctests or non-doctest tests, "
         "not both. [NOSE_IPDOCTEST_TESTS]",
     )
     parser.add_option(
         "--ipdoctest-extension",
         action="append",
         dest="ipdoctest_extension",
         help="Also look for doctests in files with " "this extension [NOSE_IPDOCTEST_EXTENSION]",
     )
     # Set the default as a list, if given in env; otherwise
     # an additional value set on the command line will cause
     # an error.
     env_setting = env.get("NOSE_IPDOCTEST_EXTENSION")
     if env_setting is not None:
         parser.set_defaults(ipdoctest_extension=tolist(env_setting))
开发者ID:kmike,项目名称:ipython,代码行数:25,代码来源:ipdoctest.py

示例12: configure

 def configure(self, options, conf):
     Plugin.configure(self, options, conf)
     conf.exclude = map(re.compile, tolist(r'^(manage\.py|.*settings\.py|apps)$'))
     
     if options.django_settings and self.env is not None:
         self.env['DJANGO_SETTINGS_MODULE'] = options.django_settings
     
     self.verbosity = conf.verbosity
开发者ID:brosner,项目名称:django-sqlalchemy,代码行数:8,代码来源:plugin.py

示例13: configure

 def configure(self, options, config):
     Plugin.configure(self, options, config)
     self.doctest_tests = options.doctest_tests
     try:
         self.extension = tolist(options.doctestExtension)
     except AttributeError:
         # 2.3, no other-file option
         self.extension = None
开发者ID:thraxil,项目名称:gtreed,代码行数:8,代码来源:doctests.py

示例14: configure

 def configure(self, options, conf):
     """
     Configure plugin.
     """
     try:
         self.status.pop('active')
     except KeyError:
         pass
     super(Coverage, self).configure(options, conf)
     if conf.worker:
         return
     if self.enabled:
         try:
             import coverage
             if not hasattr(coverage, 'coverage'):
                 raise ImportError("Unable to import coverage module")
         except ImportError:
             log.error("Coverage not available: "
                       "unable to import coverage module")
             self.enabled = False
             return
     self.conf = conf
     self.coverErase = options.cover_erase
     self.coverTests = options.cover_tests
     self.coverPackages = []
     if options.cover_packages:
         if isinstance(options.cover_packages, (list, tuple)):
             cover_packages = options.cover_packages
         else:
             cover_packages = [options.cover_packages]
         for pkgs in [tolist(x) for x in cover_packages]:
             self.coverPackages.extend(pkgs)
     if options.cover_omit:
         cover_omit = []
         for pattern in options.cover_omit:
             cover_omit.extend(pattern.split('\n'))
         options.cover_omit = cover_omit
     self.coverInclusive = options.cover_inclusive
     if self.coverPackages:
         log.info("Coverage report will include only packages: %s",
                  self.coverPackages)
     self.coverHtmlDir = None
     if options.cover_html:
         self.coverHtmlDir = options.cover_html_dir
         log.debug('Will put HTML coverage report in %s', self.coverHtmlDir)
     self.coverBranches = options.cover_branches
     self.coverXmlFile = None
     if options.cover_min_percentage:
         self.coverMinPercentage = int(options.cover_min_percentage.rstrip('%'))
     if options.cover_xml:
         self.coverXmlFile = options.cover_xml_file
         log.debug('Will put XML coverage report in %s', self.coverXmlFile)
     if self.enabled:
         self.status['active'] = True
         self.coverInstance = coverage.coverage(auto_data=False,
             branch=self.coverBranches, data_suffix=None,
             omit=options.cover_omit)
开发者ID:dvc94ch,项目名称:nose,代码行数:57,代码来源:cover.py

示例15: configure

 def configure(self, options, config):
     """Configure plugin.
     """
     Plugin.configure(self, options, config)
     self.doctest_result_var = options.doctest_result_var
     self.doctest_tests = options.doctest_tests
     self.extension = tolist(options.doctestExtension)
     self.fixtures = options.doctestFixtures
     self.finder = doctest.DocTestFinder()
开发者ID:LucianU,项目名称:kuma-lib,代码行数:9,代码来源:doctests.py


注:本文中的nose.util.tolist函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。