本文整理汇总了Python中nose.plugins.base.Plugin类的典型用法代码示例。如果您正苦于以下问题:Python Plugin类的具体用法?Python Plugin怎么用?Python Plugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Plugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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))
示例2: 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:],))
示例3: options
def options(self, parser, env=os.environ):
Plugin.options(self, parser, env)
parser.add_option("--cover-package", action="append",
default=env.get('NOSE_COVER_PACKAGE'),
dest="cover_packages",
help="Restrict coverage output to selected packages "
"[NOSE_COVER_PACKAGE]")
parser.add_option("--cover-erase", action="store_true",
default=env.get('NOSE_COVER_ERASE'),
dest="cover_erase",
help="Erase previously collected coverage "
"statistics before run")
parser.add_option("--cover-tests", action="store_true",
dest="cover_tests",
default=env.get('NOSE_COVER_TESTS'),
help="Include test modules in coverage report "
"[NOSE_COVER_TESTS]")
parser.add_option("--cover-inclusive", action="store_true",
dest="cover_inclusive",
default=env.get('NOSE_COVER_INCLUSIVE'),
help="Include all python files under working "
"directory in coverage report. Useful for "
"discovering holes in test coverage if not all "
"files are imported by the test suite. "
"[NOSE_COVER_INCLUSIVE]")
示例4: configure
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)
示例5: options
def options(self, parser, env):
"""
Register command line options
"""
parser.add_option("--marvin-config", action="store",
default=env.get('MARVIN_CONFIG', './datacenter.cfg'),
dest="config",
help="Marvin's configuration file where the " +
"datacenter information is specified " +
"[MARVIN_CONFIG]")
parser.add_option("--result-log", action="store",
default=env.get('RESULT_LOG', None),
dest="result_log",
help="The path to the results file where test " +
"summary will be written to [RESULT_LOG]")
parser.add_option("--client-log", action="store",
default=env.get('DEBUG_LOG', 'debug.log'),
dest="debug_log",
help="The path to the testcase debug logs " +
"[DEBUG_LOG]")
parser.add_option("--load", action="store_true", default=False,
dest="load",
help="Only load the deployment configuration given")
Plugin.options(self, parser, env)
示例6: 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
示例7: configure
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()
示例8: 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
示例9: __init__
def __init__(self):
Plugin.__init__(self)
self.post_data_dir = None
self.max_postdata_threshold = None
self.__save_data_count = 0
self.__priv_sn = ''
self.du = DshUtils()
示例10: __init__
def __init__(self):
Plugin.__init__(self)
self.driver = None
self.config = {}
self.environment = None
self.driver_initializer_fn = lambda _: None
self.logger = holmium.core.log
示例11: options
def options(self, parser, env):
"""Sets additional command line options."""
Plugin.options(self, parser, env)
parser.add_option(
'--tddium-output-file', action='store',
dest='tddium_output_file', metavar="FILE",
default=env.get('TDDIUM_OUTPUT_FILE', 'tddium_output.json'))
示例12: configure
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')
示例13: options
def options(self, parser, env):
"""
Sets additional command line options.
"""
Plugin.options(self, parser, env)
parser.add_option(
'--gc-per-context', action = 'store_true', dest = 'gc_per_context',
default = env.get('NOSE_GC_PER_CONTEXT', self._gcPerCtxt),
help = ("Perform garbage collection after each context. "
"Default is %s [NOSE_GC_PER_CONTEXT]" % self._gcPerCtxt)
)
parser.add_option(
'--gc-per-directory', action = 'store_true', dest = 'gc_per_directory',
default = env.get('NOSE_GC_PER_DIRECTORY', self._gcPerDir),
help = ("Perform garbage collection after each directory. "
"Default %is s [NOSE_GC_PER_DIRECTORY]" % self._gcPerDir)
)
parser.add_option(
'--gc-per-test', action = 'store_true', dest = 'gc_per_test',
default = env.get('NOSE_GC_PER_TEST', self._gcPerTest),
help = ("Perform garbage collection after each test. This can be VERY slow! "
"Default is %s [NOSE_GC_PER_TEST]" % self._gcPerTest)
)
parser.add_option(
'--gc-gen', action = 'store', dest = 'gc_gen',
default = env.get('NOSE_GC_GEN', self._gen),
help = "Garbage collection generation to run. Default is %d [NOSE_GC_GEN]" % self._gen
)
示例14: options
def options(self, parser, env):
"""
Register command line options
"""
parser.add_option("--marvin-config", action="store",
default=env.get('MARVIN_CONFIG',
'./datacenter.cfg'),
dest="configFile",
help="Marvin's configuration file is required."
"The config file containing the datacenter and "
"other management server "
"information is specified")
parser.add_option("--deploy", action="store_true",
default=False,
dest="deployDc",
help="Deploys the DC with Given Configuration."
"Requires only when DC needs to be deployed")
parser.add_option("--zone", action="store",
default=None,
dest="zone",
help="Runs all tests against this specified zone")
parser.add_option("--hypervisor", action="store",
default=None,
dest="hypervisor_type",
help="Runs all tests against the specified "
"zone and hypervisor Type")
parser.add_option("--log-folder-path", action="store",
default=None,
dest="logFolder",
help="Collects all logs under the user specified"
"folder"
)
Plugin.options(self, parser, env)
示例15: __init__
def __init__(self):
self.__identifier = None
self.__testClient = None
self.__logFolderPath = None
self.__parsedConfig = None
'''
Contains Config File
'''
self.__configFile = None
'''
Signifies the Zone against which all tests will be Run
'''
self.__zoneForTests = None
'''
Signifies the flag whether to deploy the New DC or Not
'''
self.__deployDcFlag = None
self.conf = None
self.__resultStream = stdout
self.__testRunner = None
self.__testResult = SUCCESS
self.__startTime = None
self.__testName = None
self.__tcRunLogger = None
self.__testModName = ''
self.__hypervisorType = None
'''
The Log Path provided by user where all logs are routed to
'''
self.__userLogPath = None
Plugin.__init__(self)