本文整理汇总了Python中nose.config.Config类的典型用法代码示例。如果您正苦于以下问题:Python Config类的具体用法?Python Config怎么用?Python Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: autohelp_directive
def autohelp_directive(dirname, arguments, options, content, lineno,
content_offset, block_text, state, state_machine):
"""produces rst from nose help"""
config = Config(parserClass=OptBucket,
plugins=BuiltinPluginManager())
parser = config.getParser(TestProgram.usage())
rst = ViewList()
for line in parser.format_help().split('\n'):
rst.append(line, '<autodoc>')
rst.append('Options', '<autodoc>')
rst.append('-------', '<autodoc>')
rst.append('', '<autodoc>')
for opt in parser:
rst.append(opt.options(), '<autodoc>')
rst.append(' \n', '<autodoc>')
rst.append(' ' + opt.help + '\n', '<autodoc>')
rst.append('\n', '<autodoc>')
node = nodes.section()
node.document = state.document
surrounding_title_styles = state.memo.title_styles
surrounding_section_level = state.memo.section_level
state.memo.title_styles = []
state.memo.section_level = 0
state.nested_parse(rst, 0, node, match_titles=1)
state.memo.title_styles = surrounding_title_styles
state.memo.section_level = surrounding_section_level
return node.children
开发者ID:mindw,项目名称:nose,代码行数:29,代码来源:pluginopts.py
示例2: run
def run(*arg, **kw):
"""
Specialized version of nose.run for use inside of doctests that
test test runs.
This version of run() prints the result output to stdout. Before
printing, the output is processed by replacing the timing
information with an ellipsis (...), removing traceback stacks, and
removing trailing whitespace.
Use this version of run wherever you are writing a doctest that
tests nose (or unittest) test result output.
Note: do not use doctest: +ELLIPSIS when testing nose output,
since ellipses ("test_foo ... ok") in your expected test runner
output may match multiple lines of output, causing spurious test
passes!
"""
from nose import run
from nose.config import Config
from nose.plugins.manager import PluginManager
buffer = StringIO()
if 'config' not in kw:
plugins = kw.pop('plugins', None)
env = kw.pop('env', {})
kw['config'] = Config(env=env, plugins=PluginManager(plugins=plugins))
if 'argv' not in kw:
kw['argv'] = ['nosetests', '-v']
kw['config'].stream = buffer
run(*arg, **kw)
out = buffer.getvalue()
print munge_nose_output_for_doctest(out)
开发者ID:scbarber,项目名称:horriblepoems,代码行数:33,代码来源:plugintest.py
示例3: collector
def collector():
"""TestSuite replacement entry point. Use anywhere you might use a
unittest.TestSuite. The collector will, by default, load options from
all config files and execute loader.loadTestsFromNames() on the
configured testNames, or '.' if no testNames are configured.
"""
# plugins that implement any of these methods are disabled, since
# we don't control the test runner and won't be able to run them
# finalize() is also not called, but plugins that use it aren't disabled,
# because capture needs it.
setuptools_incompat = ('report', 'prepareTest',
'prepareTestLoader', 'prepareTestRunner',
'setOutputStream')
plugins = RestrictedPluginManager(exclude=setuptools_incompat)
conf = Config(files=all_config_files(),
plugins=plugins)
conf.configure(argv=['collector'])
loader = defaultTestLoader(conf)
if conf.testNames:
suite = loader.loadTestsFromNames(conf.testNames)
else:
suite = loader.loadTestsFromNames(('.',))
return FinalizingSuiteWrapper(suite, plugins.finalize)
开发者ID:antlong,项目名称:nose,代码行数:25,代码来源:core.py
示例4: run
def run(*arg, **kw):
"""
Specialized version of nose.run for use inside of doctests that
test test runs.
This version of run() prints the result output to stdout. Before
printing, the output is processed by replacing the timing
information with an ellipsis (...), removing traceback stacks, and
removing trailing whitespace.
Use this version of run wherever you are writing a doctest that
tests nose (or unittest) test result output.
Note: do not use doctest: +ELLIPSIS when testing nose output,
since ellipses ("test_foo ... ok") in your expected test runner
output may match multiple lines of output, causing spurious test
passes!
"""
from nose import run
from nose.config import Config
from nose.plugins.manager import PluginManager
buffer = Buffer()
if 'config' not in kw:
plugins = kw.pop('plugins', [])
if isinstance(plugins, list):
plugins = PluginManager(plugins=plugins)
env = kw.pop('env', {})
kw['config'] = Config(env=env, plugins=plugins)
if 'argv' not in kw:
kw['argv'] = ['nosetests', '-v']
kw['config'].stream = buffer
# Set up buffering so that all output goes to our buffer,
# or warn user if deprecated behavior is active. If this is not
# done, prints and warnings will either be out of place or
# disappear.
stderr = sys.stderr
stdout = sys.stdout
if kw.pop('buffer_all', False):
sys.stdout = sys.stderr = buffer
restore = True
else:
restore = False
warn("The behavior of nose.plugins.plugintest.run() will change in "
"the next release of nose. The current behavior does not "
"correctly account for output to stdout and stderr. To enable "
"correct behavior, use run_buffered() instead, or pass "
"the keyword argument buffer_all=True to run().",
DeprecationWarning, stacklevel=2)
try:
run(*arg, **kw)
finally:
if restore:
sys.stderr = stderr
sys.stdout = stdout
out = buffer.getvalue()
print munge_nose_output_for_doctest(out)
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:58,代码来源:plugintest.py
示例5: test_exclude
def test_exclude(self):
s = Selector(Config())
c = Config()
c.exclude = [re.compile(r'me')]
s2 = Selector(c)
assert s.matches('test_foo')
assert s2.matches('test_foo')
assert s.matches('test_me')
assert not s2.matches('test_me')
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:10,代码来源:test_selector.py
示例6: test_ignore_files_override
def test_ignore_files_override(self):
"""Override the configuration to skip only specified files."""
c = Config()
c.ignoreFiles = [re.compile(r'^test_favourite_colour\.py$')]
s = Selector(c)
assert s.wantFile('_test_underscore.py')
assert s.wantFile('.test_hidden.py')
assert not s.wantFile('setup.py') # Actually excluded because of testMatch
assert not s.wantFile('test_favourite_colour.py')
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:10,代码来源:test_selector.py
示例7: test_mp_process_args_pickleable
def test_mp_process_args_pickleable():
test = case.Test(T('runTest'))
config = Config()
config.multiprocess_workers = 2
config.multiprocess_timeout = 0.1
runner = multiprocess.MultiProcessTestRunner(
stream=_WritelnDecorator(sys.stdout),
verbosity=2,
loaderClass=TestLoader,
config=config)
runner.run(test)
开发者ID:Osmose,项目名称:home-snippets-server-lib,代码行数:11,代码来源:test_multiprocess.py
示例8: test_isolation
def test_isolation(self):
"""root logger settings ignored"""
root = logging.getLogger('')
nose = logging.getLogger('nose')
config = Config()
config.configureLogging()
root.setLevel(logging.DEBUG)
self.assertEqual(nose.level, logging.WARN)
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:11,代码来源:test_logging.py
示例9: test_mp_process_args_pickleable
def test_mp_process_args_pickleable():
# TODO(Kumar) this test needs to be more succint.
# If you start seeing it timeout then perhaps we need to skip it again.
# raise SkipTest('this currently gets stuck in poll() 90% of the time')
test = case.Test(T('runTest'))
config = Config()
config.multiprocess_workers = 2
config.multiprocess_timeout = 5
runner = multiprocess.MultiProcessTestRunner(
stream=_WritelnDecorator(sys.stdout),
verbosity=10,
loaderClass=TestLoader,
config=config)
runner.run(test)
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:14,代码来源:test_multiprocess.py
示例10: TestIdTest
class TestIdTest(unittest.TestCase):
tests_location = "tests/data/testid/testid.py"
idfile_location = "data/testid/.noseids"
def setUp(self):
self.idfile = os.path.abspath(
os.path.join(os.path.dirname(__file__), self.idfile_location))
parser = optparse.OptionParser()
argv = [
# 0 is always program
"lode_runner",
"--failed",
"--with-id",
"--id-file=%s" % self.idfile
]
self.x = TestId()
self.x.add_options(parser, env={})
(options, args) = parser.parse_args(argv)
self.config = Config()
self.x.configure(options, self.config)
self.config.plugins = PluginManager()
self.config.plugins.addPlugin(Dataprovider())
self.config.plugins.addPlugin(TestId())
self.config.configure(argv)
def tearDown(self):
try:
os.remove(self.idfile)
except OSError:
pass
def test_load_tests_path_with_no_info_in_idfile(self):
names = self.x.loadTestsFromNames([self.tests_location])
self.assertEqual((None, [self.tests_location]), names)
def test_loaded_names_with_failing_tests_in_idfile(self):
stream = StringIO()
tests = TestLoader(config=self.config).loadTestsFromName(self.tests_location)
result = LodeTestResult(stream, None, 0)
tests.run(result)
# generate needed idfile
self.config.plugins.finalize(result)
names = self.x.loadTestsFromNames([self.tests_location])
loaded_tests = [(parse_test_name(name)[1], parse_test_name(name)[2]) for name in names[1]]
self.assertEqual(
[('DataprovidedTestCase','test_with_dataprovider_failing_on_everything_except_2_1'),
('DataprovidedTestCase','test_with_dataprovider_failing_on_everything_except_2_3')], loaded_tests)
开发者ID:z00sts,项目名称:lode_runner,代码行数:49,代码来源:test_testid.py
示例11: test_queue_manager_timing_out
def test_queue_manager_timing_out(self):
class Options(object):
gevented_timeout = .05
config = Config()
config.options = Options()
queue_manager = gmultiprocess.TestsQueueManager(config=config)
tasks = [gmultiprocess.get_task_key(('test_addr', 'arg'))]
with self.assertRaisesRegexp(Exception, 'Timing out'):
queue_manager.process_test_results(
tasks,
global_result=None,
output_stream=None,
stop_on_error=False,
)
开发者ID:dvdotsenko,项目名称:nose_gevent_multiprocess,代码行数:16,代码来源:test_gevented_multiprocess.py
示例12: DiscoverTest
class DiscoverTest(unittest.TestCase):
tests_location = "tests/data/dataprovided/dataprovided.py"
tested_test = ":TestCase.test_with_dataprovider_fixture_2"
argv = []
ran_1_test = "Ran 1 test"
no_such_test = "ValueError: No such test"
def setUp(self):
self.config = Config()
self.config.plugins = PluginManager()
self.config.plugins.addPlugin(Dataprovider())
self.config.configure(self.argv)
def tearDown(self):
del sys.modules["dataprovided"]
self.argv = []
开发者ID:sh0ked,项目名称:lode_runner,代码行数:17,代码来源:test_discover_dataprovided_test.py
示例13: test_include
def test_include(self):
s = Selector(Config())
c = Config()
c.include = [re.compile(r"me")]
s2 = Selector(c)
assert s.matches("test")
assert s2.matches("test")
assert not s.matches("meatball")
assert s2.matches("meatball")
assert not s.matches("toyota")
assert not s2.matches("toyota")
c.include.append(re.compile("toy"))
assert s.matches("test")
assert s2.matches("test")
assert not s.matches("meatball")
assert s2.matches("meatball")
assert not s.matches("toyota")
assert s2.matches("toyota")
开发者ID:GaloisInc,项目名称:echronos,代码行数:20,代码来源:test_selector.py
示例14: _execPlugin
def _execPlugin(self):
"""execute the plugin on the internal test suite.
"""
from nose.config import Config
from nose.core import TestProgram
from nose.plugins.manager import PluginManager
suite = None
stream = Buffer()
conf = Config(env=self.env,
stream=stream,
plugins=PluginManager(plugins=self.plugins))
if self.ignoreFiles is not None:
conf.ignoreFiles = self.ignoreFiles
if not self.suitepath:
suite = self.makeSuite()
self.nose = TestProgram(argv=self.argv, config=conf, suite=suite,
exit=False)
self.output = AccessDecorator(stream)
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:20,代码来源:plugintest.py
示例15: test_include
def test_include(self):
s = Selector(Config())
c = Config()
c.include = [re.compile(r'me')]
s2 = Selector(c)
assert s.matches('test')
assert s2.matches('test')
assert not s.matches('meatball')
assert s2.matches('meatball')
assert not s.matches('toyota')
assert not s2.matches('toyota')
c.include.append(re.compile('toy'))
assert s.matches('test')
assert s2.matches('test')
assert not s.matches('meatball')
assert s2.matches('meatball')
assert not s.matches('toyota')
assert s2.matches('toyota')
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:20,代码来源:test_selector.py
示例16: test_want_file
def test_want_file(self):
#logging.getLogger('nose.selector').setLevel(logging.DEBUG)
#logging.basicConfig()
c = Config()
c.where = [absdir(os.path.join(os.path.dirname(__file__), 'support'))]
base = c.where[0]
s = Selector(c)
assert not s.wantFile('setup.py')
assert not s.wantFile('/some/path/to/setup.py')
assert not s.wantFile('ez_setup.py')
assert not s.wantFile('.test.py')
assert not s.wantFile('_test.py')
assert not s.wantFile('setup_something.py')
assert s.wantFile('test.py')
assert s.wantFile('foo/test_foo.py')
assert s.wantFile('bar/baz/test.py')
assert not s.wantFile('foo.py')
assert not s.wantFile('test_data.txt')
assert not s.wantFile('data.text')
assert not s.wantFile('bar/baz/__init__.py')
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:24,代码来源:test_selector.py
示例17: setUp
def setUp(self):
self.idfile = os.path.abspath(
os.path.join(os.path.dirname(__file__), self.idfile_location))
parser = optparse.OptionParser()
argv = [
# 0 is always program
"lode_runner",
"--failed",
"--with-id",
"--id-file=%s" % self.idfile
]
self.x = TestId()
self.x.add_options(parser, env={})
(options, args) = parser.parse_args(argv)
self.config = Config()
self.x.configure(options, self.config)
self.config.plugins = PluginManager()
self.config.plugins.addPlugin(Dataprovider())
self.config.plugins.addPlugin(TestId())
self.config.configure(argv)
开发者ID:z00sts,项目名称:lode_runner,代码行数:20,代码来源:test_testid.py
示例18: usage
def usage():
conf = Config(plugins=BuiltinPluginManager())
usage_text = conf.help(nose.main.__doc__).replace('mkwiki.py', 'nosetests')
out = '{{{\n%s\n}}}\n' % usage_text
return out
开发者ID:GaloisInc,项目名称:echronos,代码行数:5,代码来源:mkwiki.py
示例19: BlacklistConfig
def BlacklistConfig(blacklist_file, excludes=()):
config = Config()
config.verbosity = 3
config.plugins = BlacklistPlugins(blacklist_file)
if excludes: config.exclude = map(re.compile, excludes)
return config
开发者ID:netcharm,项目名称:ironclad,代码行数:6,代码来源:blacklists.py
示例20: print
print("Commands...")
cmds = publish_parts(nose.commands.__doc__, reader=DocReader(),
writer_name='html')
docs['commands'] = cmds['body']
print("Changelog...")
changes = open(os.path.join(root, 'CHANGELOG'), 'r').read()
changes_html = publish_parts(changes, reader=DocReader(), writer_name='html')
docs['changelog'] = changes_html['body']
print("News...")
news = open(os.path.join(root, 'NEWS'), 'r').read()
news_html = publish_parts(news, reader=DocReader(), writer_name='html')
docs['news'] = news_html['body']
print("Usage...")
conf = Config(plugins=BuiltinPluginManager())
usage_txt = conf.help(nose.main.__doc__).replace(
'mkindex.py', 'nosetests')
docs['usage'] = '<pre>%s</pre>' % usage_txt
out = tpl % docs
index = open(os.path.join(root, 'index.html'), 'w')
index.write(out)
index.close()
readme = open(os.path.join(root, 'README.txt'), 'w')
readme.write(nose.__doc__)
readme.close()
开发者ID:GaloisInc,项目名称:echronos,代码行数:30,代码来源:mkindex.py
注:本文中的nose.config.Config类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论