本文整理汇总了Python中behave.runner.Runner.run方法的典型用法代码示例。如果您正苦于以下问题:Python Runner.run方法的具体用法?Python Runner.run怎么用?Python Runner.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类behave.runner.Runner
的用法示例。
在下文中一共展示了Runner.run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_tests
# 需要导入模块: from behave.runner import Runner [as 别名]
# 或者: from behave.runner.Runner import run [as 别名]
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: handle
# 需要导入模块: from behave.runner import Runner [as 别名]
# 或者: from behave.runner.Runner import run [as 别名]
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()
示例3: handle
# 需要导入模块: from behave.runner import Runner [as 别名]
# 或者: from behave.runner.Runner import run [as 别名]
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()
示例4: feature_new
# 需要导入模块: from behave.runner import Runner [as 别名]
# 或者: from behave.runner.Runner import run [as 别名]
def feature_new(request):
print(request.POST)
form = json.loads(request.body.decode('utf-8'))
feature = Feature(description=form['description'], finality=form['finality'], who=form['who'], purpose=form['purpose'], project_id=form['project'])
feature.save()
scenario = Scenario(given=form['given'], when=form['when'], then=form['then'], title=form['title'], feature=feature)
scenario.save()
gen_feature_file(feature.id)
conf = Configuration('media/features/{}.feature'.format(feature.id))
conf.format = [ conf.default_format ]
runner = Runner(conf)
runner.run()
filename = make_test_funcs(runner.undefined_steps, feature.id)
add_to_repo(filename, feature.description)
return HttpResponse()
示例5: runTest
# 需要导入模块: from behave.runner import Runner [as 别名]
# 或者: from behave.runner.Runner import run [as 别名]
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
# 需要导入模块: from behave.runner import Runner [as 别名]
# 或者: from behave.runner.Runner import run [as 别名]
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
# 需要导入模块: from behave.runner import Runner [as 别名]
# 或者: from behave.runner.Runner import run [as 别名]
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))
示例8: main
# 需要导入模块: from behave.runner import Runner [as 别名]
# 或者: from behave.runner.Runner import run [as 别名]
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))
示例9: main
# 需要导入模块: from behave.runner import Runner [as 别名]
# 或者: from behave.runner.Runner import run [as 别名]
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
# 需要导入模块: from behave.runner import Runner [as 别名]
# 或者: from behave.runner.Runner import run [as 别名]
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
# 需要导入模块: from behave.runner import Runner [as 别名]
# 或者: from behave.runner.Runner import run [as 别名]
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
# 需要导入模块: from behave.runner import Runner [as 别名]
# 或者: from behave.runner.Runner import run [as 别名]
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: home
# 需要导入模块: from behave.runner import Runner [as 别名]
# 或者: from behave.runner.Runner import run [as 别名]
def home(request):
"""Renders the home page."""
assert isinstance(request, HttpRequest)
if request.method != 'POST':
form = FeatureForm()
return render(
request,
'app/index.html',
context_instance = RequestContext(request,
{
'title':'Home Page',
'year':datetime.now().year,
'form': form,
})
)
else:
form = FeatureForm(request.POST)
if form.is_valid():
feature = Feature(description=form.cleaned_data['description'], finality=form.cleaned_data['finality'], who=form.cleaned_data['who'], purpose=form.cleaned_data['purpose'])
feature.save()
scenario = Scenario(given=form.cleaned_data['given'], when=form.cleaned_data['when'], then=form.cleaned_data['then'], title=form.cleaned_data['title'], feature=feature)
scenario.save()
gen_feature_file(feature.id)
conf = Configuration(os.path.join(settings.PROJECT_ROOT, 'media', 'features', '{}.feature'.format(feature.id)))
conf.format = [ conf.default_format ]
runner = Runner(conf)
runner.run()
filename = make_test_funcs(runner.undefined_steps, feature.id)
add_to_repo(filename, feature.description)
return render( request,
'app/index.html',
context_instance = RequestContext(request,
{
'title':'Home Page',
'year':datetime.now().year,
'form': form,
})
)
示例14: run_tests
# 需要导入模块: from behave.runner import Runner [as 别名]
# 或者: from behave.runner.Runner import run [as 别名]
def run_tests(room, vendor, tags, override):
app = create_app()
with app.app_context():
test_run = TestRun(vendor, tags)
db.session.add(test_run)
db.session.commit()
def on_snapshot(snapshot, plan):
test_run.save_snapshot(snapshot, plan)
socketio.emit('snapshot', test_run.event, room=room)
db.session.commit()
def on_payload(payload):
socketio.emit('payload', payload, room=room)
try:
output = io.StringIO()
output_stream = StreamOpener(stream=output)
config = Configuration(
outputs=[output_stream],
format=['json.chunked'],
on_snapshot=on_snapshot,
on_payload=on_payload,
vendor=vendor,
override=override,
command_args=[],
tags=[','.join(tags)],
)
runner = Runner(config)
runner.run()
except Exception as err: # pylint: disable=broad-except
import traceback
traceback.print_exc()
socketio.emit('global_error', str(err), room=room)
finally:
socketio.emit('tests_complete', room=room)
示例15: run_model_with_cmdline
# 需要导入模块: from behave.runner import Runner [as 别名]
# 或者: from behave.runner.Runner import run [as 别名]
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()