本文整理汇总了Python中behave.runner.Runner类的典型用法代码示例。如果您正苦于以下问题:Python Runner类的具体用法?Python Runner怎么用?Python Runner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Runner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_tests
def run_tests(room, vendor, tags, override):
def on_snapshot(snapshot, plan):
event = {
'snapshot': snapshot,
'plan': plan,
}
socketio.emit('snapshot', event, room=room)
try:
output = io.StringIO()
output_stream = StreamOpener(stream=output)
config = Configuration(
outputs=[output_stream],
format=['json.chunked'],
on_snapshot=on_snapshot,
vendor=vendor,
override=override,
command_args=[],
tags=[','.join(tags)],
)
runner = Runner(config)
runner.run()
except Exception as err: # pylint: disable=broad-except
socketio.emit('global_error', str(err))
finally:
socketio.emit('tests_complete', room=room)
示例2: test_simple_testcase_fails_when_accessing_base_url
def test_simple_testcase_fails_when_accessing_base_url(self):
runner = Runner(mock.MagicMock())
runner.context = Context(runner)
SimpleTestRunner().patch_context(runner.context)
SimpleTestRunner().setup_testclass(runner.context)
with pytest.raises(AssertionError):
assert runner.context.base_url == 'should raise an exception!'
示例3: test_simple_testcase_fails_when_calling_get_url
def test_simple_testcase_fails_when_calling_get_url(self):
runner = Runner(mock.MagicMock())
runner.context = Context(runner)
SimpleTestRunner().patch_context(runner.context)
SimpleTestRunner().setup_testclass(runner.context)
with pytest.raises(AssertionError):
runner.context.get_url()
示例4: handle
def handle(path):
file_conf = ConfigObj(os.path.join(path, 'features', 'config.ini'))
behave_options = file_conf['behave']['options']
conf = Configuration(behave_options)
conf.paths = [os.path.join(path, 'features')]
runner = Runner(conf)
runner.run()
示例5: runTest
def runTest(self, result=None):
"""Run behave on a single directory."""
# from behave/__main__.py
runner = Runner(self.behave_config)
try:
failed = runner.run()
except ParserError, e:
sys.exit(str(e))
示例6: runTest
def runTest(self, result=None):
print "run: features_dir=%s" % (self.features_dir)
stream = self.behave_config.output
runner = Runner(self.behave_config)
try:
failed = runner.run()
except ParserError, e:
sys.exit(str(e))
示例7: main
def main():
# pylint: disable=R0912,R0915
# R0912 Too many branches (17/12)
# R0915 Too many statements (57/50)
config = Configuration()
if config.version:
print "behave " + __version__
sys.exit(0)
if config.tags_help:
print TAG_HELP
sys.exit(0)
if config.lang_list:
iso_codes = languages.keys()
iso_codes.sort()
print "Languages available:"
for iso_code in iso_codes:
native = languages[iso_code]["native"][0]
name = languages[iso_code]["name"][0]
print u"%s: %s / %s" % (iso_code, native, name)
sys.exit(0)
if config.lang_help:
if config.lang_help not in languages:
sys.exit("%s is not a recognised language: try --lang-list" % config.lang_help)
trans = languages[config.lang_help]
print u"Translations for %s / %s" % (trans["name"][0], trans["native"][0])
for kw in trans:
if kw in "name native".split():
continue
print u"%16s: %s" % (kw.title().replace("_", " "), u", ".join(w for w in trans[kw] if w != "*"))
sys.exit(0)
if not config.format:
format0 = config.defaults["format0"]
config.format = [format0]
elif "help" in config.format:
print "Available formatters:"
formatters.list_formatters(sys.stdout)
sys.exit(0)
# -- SANITY: Use at most one formatter, more cause various problems.
# PROBLEM DESCRIPTION:
# 1. APPEND MODE: configfile.format + --format
# 2. Daisy chaining of formatters does not work
# => behave.formatter.formatters.get_formatter()
# => Stream methods, stream.write(), stream.flush are missing
# in Formatter interface
config.format = config.format[-1:]
stream = config.output
runner = Runner(config)
try:
failed = runner.run()
except ParserError, e:
sys.exit(str(e))
示例8: main
def main():
config = Configuration()
if config.version:
print "behave " + __version__
sys.exit(0)
if config.tags_help:
print TAG_HELP
sys.exit(0)
if config.lang_list:
iso_codes = languages.keys()
iso_codes.sort()
print "Languages available:"
for iso_code in iso_codes:
native = languages[iso_code]['native'][0]
name = languages[iso_code]['name'][0]
print u'%s: %s / %s' % (iso_code, native, name)
sys.exit(0)
if config.lang_help:
if config.lang_help not in languages:
sys.exit('%s is not a recognised language: try --lang-list' %
config.lang_help)
trans = languages[config.lang_help]
print u"Translations for %s / %s" % (trans['name'][0],
trans['native'][0])
for kw in trans:
if kw in 'name native'.split():
continue
print u'%16s: %s' % (kw.title().replace('_', ' '),
u', '.join(w for w in trans[kw] if w != '*'))
sys.exit(0)
if not config.format:
format0 = config.defaults["format0"]
config.format = [ format0 ]
elif 'help' in config.format:
print "Available formatters:"
formatters.list_formatters(sys.stdout)
sys.exit(0)
# -- SANITY: Use at most one formatter, more cause various problems.
# PROBLEM DESCRIPTION:
# 1. APPEND MODE: configfile.format + --format
# 2. Daisy chaining of formatter does not work
# => behave.formatter.formatters.get_formatter()
# => Stream methods, stream.write(), stream.flush are missing
# in Formatter interface
if DISABLE_MULTI_FORMATTERS:
config.format = config.format[-1:]
runner = Runner(config)
try:
failed = runner.run()
except ParserError, e:
sys.exit(str(e))
示例9: main
def main():
config = Configuration()
if config.version:
print "behave " + __version__
sys.exit(0)
if config.tags_help:
print TAG_HELP
sys.exit(0)
if config.lang_list:
iso_codes = languages.keys()
iso_codes.sort()
print "Languages available:"
for iso_code in iso_codes:
native = languages[iso_code]["native"][0]
name = languages[iso_code]["name"][0]
print u"%s: %s / %s" % (iso_code, native, name)
sys.exit(0)
if config.lang_help:
if config.lang_help not in languages:
sys.exit("%s is not a recognised language: try --lang-list" % config.lang_help)
trans = languages[config.lang_help]
print u"Translations for %s / %s" % (trans["name"][0], trans["native"][0])
for kw in trans:
if kw in "name native".split():
continue
print u"%16s: %s" % (kw.title().replace("_", " "), u", ".join(w for w in trans[kw] if w != "*"))
sys.exit(0)
if not config.format:
default_format = config.defaults["default_format"]
config.format = [default_format]
elif config.format and "format" in config.defaults:
# -- CASE: Formatter are specified in behave configuration file.
# Check if formatter are provided on command-line, too.
if len(config.format) == len(config.defaults["format"]):
# -- NO FORMATTER on command-line: Add default formatter.
default_format = config.defaults["default_format"]
config.format.append(default_format)
if "help" in config.format:
print "Available formatters:"
formatters.list_formatters(sys.stdout)
sys.exit(0)
if len(config.outputs) > len(config.format):
print "CONFIG-ERROR: More outfiles (%d) than formatters (%d)." % (len(config.outputs), len(config.format))
sys.exit(1)
runner = Runner(config)
try:
failed = runner.run()
except ParserError, e:
sys.exit("ParseError: %s" % e)
示例10: runTest
def runTest(self, result=None):
# run behave on a single directory
print "run: features_dir=%s" % (self.features_dir)
# from behave/__main__.py
runner = Runner(self.behave_config)
try:
failed = runner.run()
except ParserError, e:
sys.exit(str(e))
示例11: runTest
def runTest(self, result=None):
# run behave on a single directory
# from behave/__main__.py
#stream = self.behave_config.output
runner = BehaveRunner(self.behave_config)
try:
failed = runner.run()
except ParserError, e:
sys.exit(str(e))
示例12: runTest
def runTest(self, result=None):
DjangoTestCaseAccessor.test_case = self
# run behave on a single directory
print "Run test in transaction for feature_paths=%s" % self.feature_paths
# from behave/__main__.py
runner = Runner(self.behave_config)
try:
failed = runner.run()
except ParserError, e:
sys.exit(str(e))
示例13: handle
def handle(path, args=None):
file_conf = ConfigObj(os.path.join(path, "features", "config.ini"))
try:
behave_options = file_conf["behave"]["options"]
except KeyError:
raise ValueError("Behave config not found." " Are you running with the right path?")
if args:
behave_options += " " + " ".join(args)
conf = Configuration(behave_options)
conf.paths = [os.path.join(path, "features")]
runner = Runner(conf)
runner.run()
示例14: handle
def handle(path, args=None):
file_conf = ConfigObj(os.path.join(path, 'features', 'config.ini'))
try:
behave_options = file_conf['behave']['options']
except KeyError:
raise ValueError("Behave config not found."
" Are you running with the right path?")
if args:
behave_options += ' ' + ' '.join(args)
conf = Configuration(behave_options)
conf.paths = [os.path.join(path, 'features')]
runner = Runner(conf)
return runner.run()
示例15: run_model_with_cmdline
def run_model_with_cmdline(model, cmdline):
reset_model(model.features)
command_args = cmdline
config = Configuration(command_args,
load_config=False,
default_format="null",
stdout_capture=True,
stderr_capture=True,
log_capture=False,
junit=True)
model_runner = ModelRunner(config, model.features)
runner = Runner(model_runner)
runner.setup_paths()
return runner.run()