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:],))
def configure(self, options, config): Plugin.configure(self, options, config) if not self.enabled: return self.verbosity = options.verbosity if options.quickunit_prefix: self.prefixes = options.quickunit_prefix if len(self.prefixes) == 1: self.prefixes = self.prefixes[0].split('\n') else: self.prefixes = ["tests/"] self.parent = 'master' self.logger = logging.getLogger(__name__) # pending files becomes a set of directorie pieces that represent # the file locations changed in this diff # for example, if /foo/bar/baz.py was changed, pending files would contain # set([('foo', 'bar', 'baz')]) self.pending_files = set() # diff is a mapping of filename->set(linenos) self.diff_data = defaultdict(set) # store a list of filenames that should be accepted self.file_cache = FileAcceptedCache(self.prefixes, self.pending_files, self.diff_data)
def configure(self, options, config): """Configures the html-xxx plugin.""" super(HtmlOutput, self).configure(options, config) Plugin.configure(self, options, config) self.config = config if options.html_file: self.html_file = options.html_file if options.html_title: self.html_title = options.html_title if self.enabled: self.start_time = datetime.datetime.now() self.jinja = jinja2.Environment(loader=jinja2.FileSystemLoader( os.path.dirname(options.html_template)), trim_blocks=True, lstrip_blocks=True) self.jinja_template = options.html_template if not hasattr(self.config, '_nose_html_output_state'): manager = multiprocessing.Manager() self.errorlist = manager.list() self.stats = manager.dict(**{ 'errors': 0, 'failures': 0, 'passes': 0, 'skipped': 0 }) self.config._nose_html_output_state = self.errorlist, self.stats else: self.errorlist, self.stats = self.config._nose_html_output_state self.error_report_file_name = os.path.realpath(options.html_file) self.html_file_name = options.html_file
def configure(self, options, config): # it is overriden in order to fix doctest options discovery 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() #super(DoctestPluginHelper, self).configure(options, config) self.optionflags = 0 if options.doctestOptions: flags = ",".join(options.doctestOptions).split(',') for flag in flags: try: if flag.startswith('+'): self.optionflags |= doctest.OPTIONFLAGS_BY_NAME[ flag[1:]] elif flag.startswith('-'): self.optionflags &= ~doctest.OPTIONFLAGS_BY_NAME[ flag[1:]] else: raise ValueError( "Must specify doctest options with starting " + "'+' or '-'. Got %s" % (flag, )) except (AttributeError, KeyError): raise ValueError("Unknown doctest option %s" % (flag[1:], ))
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
def configure(self, options, config): Plugin.configure(self, options, config) if not self.enabled: return self.verbosity = options.verbosity if options.quickunit_prefix: self.prefixes = options.quickunit_prefix if len(self.prefixes) == 1: self.prefixes = self.prefixes[0].split('\n') else: self.prefixes = ["tests/"] self.parent = 'master' self.logger = logging.getLogger(__name__) # pending files becomes a set of directorie pieces that represent # the file locations changed in this diff # for example, if /foo/bar/baz.py was changed, pending files would contain # set([('foo', 'bar', 'baz')]) self.pending_files = set() # diff is a mapping of filename->set(linenos) self.diff_data = defaultdict(set) # store a list of filenames that should be accepted self.file_cache = FileAcceptedCache(self.prefixes, self.pending_files, self.diff_data)
def configure(self, options, noseconfig): """ Call the super and then validate and call the relevant parser for the configuration file passed in """ from ..interfaces.xmlrpc import BugzillaInterface from ..interfaces.config import ConfigInterface import f5test.commands.icontrol as ICMD import f5test.commands.testopia as TCMD Plugin.configure(self, options, noseconfig) self.options = options if options.with_testopia or options.syncplan: self.enabled = True else: return self.config_ifc = ConfigInterface() testopia = self.config_ifc.api.testopia self.testopia_ifc = BugzillaInterface(testopia.address, testopia.username, testopia.password) self.ICMD = ICMD self.TCMD = TCMD self.product = 'Enterprise Manager' self.tcs = {} self.tcs_ran = set()
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
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
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))
def configure(self, options, config): Plugin.configure(self, options, config) if not self.enabled: return config = read_config(options.kleenex_config, options.kleenex_config_section) self.config = config assert not (self.config.discover and self.config.record), "You cannot use both `record` and `discover` options." self.logger = logging.getLogger(__name__) self.pending_funcs = set() # diff is a mapping of filename->set(linenos) self.diff_data = defaultdict(set) # cov is a mapping of filename->set(linenos) self.cov_data = defaultdict(set) # test test_name->dict(filename->set(linenos)) self.test_data = defaultdict(dict) report_output = config.report_output if not report_output or report_output == '-': self.report_file = None elif report_output.startswith('sys://'): pipe = report_output[6:] assert pipe in ('stdout', 'stderr') self.report_file = getattr(sys, pipe) else: self.report_file = open(report_output, 'w')
def configure(self, options, noseconfig): """ Call the super and then validate and call the relevant parser for the configuration file passed in """ from ..interfaces.xmlrpc import BugzillaInterface from ..interfaces.config import ConfigInterface import f5test.commands.icontrol as ICMD import f5test.commands.testopia as TCMD Plugin.configure(self, options, noseconfig) self.options = options if options.with_testopia or options.syncplan: self.enabled = True else: return self.config_ifc = ConfigInterface() testopia = self.config_ifc.api.testopia self.testopia_ifc = BugzillaInterface(testopia.address, testopia.username, testopia.password) self.ICMD = ICMD self.TCMD = TCMD self.product = 'Enterprise Manager' self.tcs = {} self.tcs_ran = set()
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
def configure(self, options, config): """Configures the xunit plugin.""" Plugin.configure(self, options, config) self.config = config if self.enabled: self.stats = {"errors": 0, "failures": 0, "passes": 0, "skipped": 0} self.errorlist = [] self.error_report_file = codecs.open(options.xunit_file, "w", self.encoding, "replace")
def configure(self, options, config): Plugin.configure(self, options, config) alfajor_options = {} for key, value in vars(options).iteritems(): if key.startswith('alfajor_'): short = key[len('alfajor_'):] alfajor_options[short] = value self.options = alfajor_options
def configure(self, options, config): """Configures the plugin.""" Plugin.configure(self, options, config) self.config = config if self.enabled: self.output_file = options.tddium_output_file self.byfile = {} self.basepath = os.path.abspath('.') + '/'
def configure(self, options, config): Plugin.configure(self, options, config) alfajor_options = {} for key, value in vars(options).iteritems(): if key.startswith('alfajor_'): short = key[len('alfajor_'):] alfajor_options[short] = value self.options = alfajor_options
def configure(self, options, conf): Plugin.configure(self, options, conf) self.pattern = options.pattern if options.verbosity >= 2: self.verbose = True if self.enabled: err.write("Pattern for matching test methods is %s\n" % self.pattern)
def configure(self, options, config): """Configures the plugin.""" Plugin.configure(self, options, config) self.config = config if self.enabled: self.output_file = options.tddium_output_file self.byfile = {} self.basepath = os.path.abspath('.') + '/'
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()
def configure(self, options, config): """Configure which kinds of failures trigger plugin.""" Plugin.configure(self, options, config) self.config = config if self.enabled: if options.debugFailures and options.debugErrors: raise ValueError("--errors-only and --failures-only are mutually exclusive") self.enabled_for_errors = not options.debugFailures self.enabled_for_failures = not options.debugErrors
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 self.finder = doctest.DocTestFinder()
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()
def configure(self, options, config): # parent method sets enabled flag from command line --with-numpydoctest Plugin.configure(self, options, config) self.finder = self.test_finder_class() self.parser = doctest.DocTestParser() if self.enabled: # Pull standard doctest out of plugin list; there's no reason to run # both. In practice the Unplugger plugin above would cover us when # run from a standard numpy.test() call; this is just in case # someone wants to run our plugin outside the numpy.test() machinery config.plugins.plugins = [p for p in config.plugins.plugins if p.name != "doctest"]
def configure(self, options, config): """Configures the xunit plugin.""" Plugin.configure(self, options, config) self.config = config if self.enabled: self.xunitstream = globalxunitstream self.xunitstats = globalxunitstats for i in range(4): self.xunitstats[i] = 0 self.xunit_file = options.xunit_file self.xunit_header = options.xunit_header
def configure(self, options, config): """Configures the xunit plugin.""" Plugin.configure(self, options, config) self.config = config if self.enabled: self.stats = {"errors": 0, "failures": 0, "passes": 0, "skipped": 0} self.errorlist = [] if UNICODE_STRINGS: self.error_report_file = open(options.xunit_file, "w", encoding=self.encoding) else: self.error_report_file = open(options.xunit_file, "w")
def configure(self, options, config): """ Configures the gc plugin. """ Plugin.configure(self, options, config) self.config = config if self.enabled: self._gen = int(options.gc_gen) self._gcPerCtxt = options.gc_per_context self._gcPerDir = options.gc_per_directory self._gcPerTest = options.gc_per_test
def configure(self, options, config): # parent method sets enabled flag from command line --with-numpydoctest Plugin.configure(self, options, config) self.finder = self.test_finder_class() self.parser = doctest.DocTestParser() if self.enabled: # Pull standard doctest out of plugin list; there's no reason to run # both. In practice the Unplugger plugin above would cover us when # run from a standard numpy.test() call; this is just in case # someone wants to run our plugin outside the numpy.test() machinery config.plugins.plugins = [p for p in config.plugins.plugins if p.name != 'doctest']
def configure(self, options, conf): """Configure plugin. """ Plugin.configure(self, options, conf) self.conf = conf if options.profile_stats_file: self.pfile_name = options.profile_stats_file else: self.pfile_name = 'stats.dat' self.fileno = None if options.stats_erase: self._erase_stats_file()
def configure(self, options, config): """Configures the xunit plugin.""" Plugin.configure(self, options, config) self.config = config if self.enabled: self.stats = {'errors': 0, 'failures': 0, 'passes': 0, 'skipped': 0 } self.errorlist = [] self.error_report_file_name = os.path.realpath(options.xunit_file)
def configure(self, options, conf): """Configure plugin. """ Plugin.configure(self, options, conf) self.conf = conf if options.profile_stats_file: self.pfile_name = options.profile_stats_file else: self.pfile_name = "stats.dat" self.fileno = None if options.stats_erase: self._erase_stats_file()
def configure(self, options, config): """Configures the testdata plugin.""" Plugin.configure(self, options, config) self.config = config self.reportdata = [] if options.testdata_table: self.format = 'table' else: self.format = 'sparse' if self.enabled: self.report_file = open(options.testdata_file, 'w') self.datakeys.add('time')
def configure(self, options, config): """Configures the testdata plugin.""" Plugin.configure(self, options, config) self.config = config self.reportdata = [] if options.testdata_table: self.format = 'table' else: self.format = 'sparse' if self.enabled: self.report_file = open(options.testdata_file, 'w') self.datakeys.add('time')
def configure(self, options, config): """Configures the xunit plugin.""" Plugin.configure(self, options, config) self.config = config if self.enabled: self.stats = {'errors': 0, 'failures': 0, 'passes': 0, 'skipped': 0 } self.errorlist = [] self.error_report_file_name = options.xunit_file
def configure(self, options, config): """Configures the xunit plugin.""" Plugin.configure(self, options, config) self.config = config if self.enabled: self.stats = {'errors': 0, 'failures': 0, 'passes': 0, 'skipped': 0 } self.errorlist = [] self.error_report_file = codecs.open(options.xunit_file, 'w', self.encoding, 'replace')
def configure(self, options, config): """Configures the xunit plugin.""" Plugin.configure(self, options, config) self.config = config if self.enabled: self.stats = MP_STATS self.stats.update( {'errors': 0, 'failures': 0, 'passes': 0, 'skipped': 0}) self.errorlist = MP_ERRORLIST self.error_report_filename = options.xunitmp_file
def configure(self, options, config): """Configures the xunit plugin.""" Plugin.configure(self, options, config) self.config = config if self.enabled: self.stats = {'errors': 0, 'failures': 0, 'passes': 0, 'skipped': 0 } self.errorlist = [] self.error_report_file = codecs.open(options.xunit_file, 'w', self.encoding, 'replace')
def configure(self, options, config): """Configures the xunit plugin.""" Plugin.configure(self, options, config) self.config = config if self.enabled: self.stats = MP_STATS self.stats.update( {'errors': 0, 'failures': 0, 'passes': 0, 'skipped': 0}) self.errorlist = MP_ERRORLIST self.error_report_filename = options.xunitmp_file
def configure(self, options, config): """Configures the xunit plugin.""" Plugin.configure(self, options, config) self.config = config if self.enabled: self.stats = {'errors': 0, 'failures': 0, 'passes': 0, 'skipped': 0 } self.errorlist = [] self.error_report_file_name = os.path.realpath(options.xunit_file) self.xunit_testsuite_name = options.xunit_testsuite_name self.xunit_prefix_class = options.xunit_prefix_class
def configure(self, options, conf): Plugin.configure(self, options, conf) self.options = options self.conf = conf if options.profile_stats_file: self.pfile = options.profile_stats_file self.clean_stats_file = False else: self.pfile = None self.clean_stats_file = True self.fileno = None self.sort = options.profile_sort self.restrict = tolist(options.profile_restrict)
def configure(self, options, config): """Configures the xunit plugin.""" Plugin.configure(self, options, config) self.config = config if self.enabled: if hasattr(options, 'multiprocess_workers') and options.multiprocess_workers: if multiprocessing.current_process().name == 'MainProcess': Xunit.mp_context = MultiprocessContext() self.stats = Xunit.mp_context.stats self.errorlist = Xunit.mp_context.error_list else: super(Xunit, self).configure(options, config) self.error_report_filename = options.xunit_file
def configure(self, options, conf): Plugin.configure(self, options, conf) self.enabled = True try: from coverage import coverage except ImportError: self.enabled = False self.cov = None print('Module "coverage" not installed, code coverage will not ' 'be available') else: self.enabled = True self.cov = coverage(auto_data=False, branch=True, data_suffix=None, source=['vispy'])
def configure(self, options, config): Plugin.configure(self, options, config) if not self.enabled: return self.verbosity = options.verbosity if options.quickunit_prefix: self.prefixes = options.quickunit_prefix if len(self.prefixes) == 1: self.prefixes = self.prefixes[0].split('\n') else: self.prefixes = ["tests/"] self.parent = 'master' self.logger = logging.getLogger(__name__) self.pending_files = set() # diff is a mapping of filename->set(linenos) self.diff_data = defaultdict(set) # coverate data which was discovered when a test was run # test name -> {filename: {linenos}} self.test_cov_data = defaultdict(lambda: defaultdict(set)) # coverage data which was discovered at time of module import # imported module name -> {filename: {linenos}} self.importtime_cov_data = defaultdict(lambda: defaultdict(set)) # maps a test name to a module # test name -> module name self.test_to_module_map = dict() # the root directory of our diff (this is basically cwd) self.root = None report_output = options.quickunit_output if not report_output or report_output == '-': self.report_file = None elif report_output.startswith('sys://'): pipe = report_output[6:] assert pipe in ('stdout', 'stderr') self.report_file = getattr(sys, pipe) else: path = os.path.dirname(report_output) if not os.path.exists(path): os.makedirs(path) self.report_file = open(report_output, 'w')
def configure(self, options, conf): if not self.available(): self.enabled = False return Plugin.configure(self, options, conf) self.conf = conf if options.profile_stats_file: self.pfile = options.profile_stats_file self.clean_stats_file = False else: self.pfile = None self.clean_stats_file = True self.fileno = None self.sort = options.profile_sort self.restrict = tolist(options.profile_restrict)
def configure(self, options, conf): if not self.available(): self.enabled = False return Plugin.configure(self, options, conf) self.conf = conf if options.profile_stats_file: self.pfile = options.profile_stats_file self.clean_stats_file = False else: self.pfile = None self.clean_stats_file = True self.fileno = None self.sort = options.profile_sort self.restrict = tolist(options.profile_restrict)
def configure(self, options, config): Plugin.configure(self, options, config) # Do nothing if plugin not enabled if not self.enabled: return # Check that Django and twill libraries available in this system if self.enabled: for lib in ('Django', 'twill'): try: __import__(lib.lower()) except ImportError, e: log.error('%s not available: %s' % (lib, e)) self.enabled = False return
def configure(self, options, config): """Configures the xunit plugin.""" Plugin.configure(self, options, config) self.config = config if self.enabled: if hasattr( options, 'multiprocess_workers') and options.multiprocess_workers: if multiprocessing.current_process().name == 'MainProcess': Xunit.mp_context = MultiprocessContext() self.stats = Xunit.mp_context.stats self.errorlist = Xunit.mp_context.error_list self.xunit_testsuite_name = options.xunit_testsuite_name else: super(Xunit, self).configure(options, config) self.error_report_filename = options.xunit_file
def configure(self, options, config): """Configures the xunit plugin.""" Plugin.configure(self, options, config) self.config = config if self.enabled: try: dirs = os.environ[envvar_name].split(',') except KeyError: dirs = [None for name in range(len(stat_names) + 1)] self.stats = { name: OnDiskCounter(dirs.pop(0)) for name in stat_names } self.errorlist = OnDiskList(directory=dirs.pop(0)) os.environ[envvar_name] = ','.join( [self.stats[s].directory for s in stat_names] + [self.errorlist.directory]) self.error_report_filename = options.xunit_gevent_file
def configure(self, options, config): """Configures the xunit plugin.""" Plugin.configure(self, options, config) self.config = config if self.enabled: self.stats = { 'errors': 0, 'failures': 0, 'passes': 0, 'skipped': 0 } self.errorlist = [] if UNICODE_STRINGS: self.error_report_file = open(options.xunit_file, 'w', encoding=self.encoding) else: self.error_report_file = open(options.xunit_file, 'w')
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.tc_file: return self.enabled = True Plugin.configure(self, options, noseconfig) loader = ConfigLoader(options.tc_file, options.tc_format) with Signals.on_before_extend.connected_to(self.callbacks['on_before_extend']), \ Signals.on_after_extend.connected_to(self.callbacks['on_after_extend']): cfgifc = ConfigInterface(loader=loader) cfgifc.set_global_config() config = cfgifc.get_config() if options.tc_debug_open_contexts: atexit.register(print_open_contexts) if options.overrides: self.overrides = [] overrides = set(tolist(options.overrides)) for override in overrides: keys, val = override.split(":", 1) # Attempt to convert the string into int/bool/float or default # to string if val == '': val = None else: needquotes = False try: val = ast.literal_eval(val) except ValueError: needquotes = True if needquotes or isinstance(val, basestring): val = '"%s"' % val if options.tc_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))
def configure(self, options, config): """Activate coverage plugin if appropriate.""" log.debug('nose-cov configure') try: self.status.pop('active') except KeyError: pass Plugin.configure(self, options, config) if self.enabled and not config.worker: self.status['active'] = True self.cov_source = options.cov_source or ['.'] self.cov_report = options.cov_report or ['term'] self.cov_config = options.cov_config else: self.enabled = False
def configure(self, options, config): """ Configure plugin. """ try: self.status.pop('active') except KeyError: pass Plugin.configure(self, options, config) if getattr(config, "worker", None) and config.worker: return 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.coverBranch = options.cover_branch self.coverExclude = options.cover_exclude or [] if isinstance(self.coverExclude, str): self.coverExclude = RE_LIST.split(self.coverExclude) self.coverXml = options.cover_xml self.coverXmlFile = options.cover_xml_file 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
def configure(self, options, config): # it is overriden in order to fix doctest options discovery 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() #super(DoctestPluginHelper, self).configure(options, config) self.optionflags = 0 self.options = {} if options.doctestOptions: stroptions = ",".join(options.doctestOptions).split(',') for stroption in stroptions: try: if stroption.startswith('+'): self.optionflags |= doctest.OPTIONFLAGS_BY_NAME[ stroption[1:]] continue elif stroption.startswith('-'): self.optionflags &= ~doctest.OPTIONFLAGS_BY_NAME[ stroption[1:]] continue try: key, value = stroption.split('=') except ValueError: pass else: if not key in self.OPTION_BY_NAME: raise ValueError() self.options[key] = value continue except (AttributeError, ValueError, KeyError): raise ValueError( "Unknown doctest option {}".format(stroption)) else: raise ValueError( "Doctest option is not a flag or a key/value pair: {} " .format(stroption))
def configure(self, options, noseconfig): """ Call the super and then validate and call the relevant parser for the configuration file passed in """ if options.testconfig == [None]: raise FrameworkException("No test-config specified (--tc-file)") if not options.testconfig and not options.overrides: 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: for configfile in options.testconfig: if configfile: self.valid_loaders[self.format](configfile, options.testconfigencoding) overrides = tolist(options.overrides) or [] for override in overrides: keys, val = override.split(":", 1) if options.exact: config[keys] = val else: # Create all *parent* keys that may not exist in the config section = config keys = keys.split('.') for key in keys[:-1]: if key not in section: section[key] = {} section = section[key] # Finally assign the value to the last key key = keys[-1] section[key] = val
def configure(self, options, config): ### configure logging logger = logging.getLogger(__name__) logger.propagate = 0 handler = logging.StreamHandler(err) logger.addHandler(handler) logger.setLevel(logging.WARNING) Plugin.configure(self, options, config) ### configure stopwatch stuff: file containing times, and ### time cutoff. self.stopwatch_file = os.path.abspath(options.stopwatch_file) self.faster_than = options.faster_than log.info('stopwatch module: using "%s" for stopwatch times' % \ (self.stopwatch_file,)) log.info('selecting tests that run faster than %s seconds' % \ (self.faster_than,))
def configure(self, options, config): 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)