当前位置: 首页>>代码示例>>Python>>正文


Python Runner.run方法代码示例

本文整理汇总了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)
开发者ID:Cphrampus,项目名称:test-suite,代码行数:30,代码来源:tasks.py

示例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()
开发者ID:Cito,项目名称:zato-apitest,代码行数:10,代码来源:run.py

示例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()
开发者ID:universsky,项目名称:zato-apitest,代码行数:15,代码来源:run.py

示例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()
开发者ID:mreguero,项目名称:don_stephen,代码行数:18,代码来源:views.py

示例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))
开发者ID:jaydev,项目名称:django-behave,代码行数:10,代码来源:runner.py

示例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))
开发者ID:mattjmorrison,项目名称:icc2012-rolodex-service,代码行数:10,代码来源:runner.py

示例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))
开发者ID:jgr21,项目名称:behave,代码行数:59,代码来源:__main__.py

示例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))
开发者ID:hangtwenty,项目名称:behave,代码行数:59,代码来源:main.py

示例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)
开发者ID:vhumpa,项目名称:behave,代码行数:58,代码来源:__main__.py

示例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))
开发者ID:scottferg,项目名称:django-jenkins,代码行数:12,代码来源:behave_tests.py

示例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))
开发者ID:Mondego,项目名称:pyreco,代码行数:12,代码来源:allPythonContent.py

示例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))
开发者ID:mackeian,项目名称:django-behave,代码行数:13,代码来源:runner.py

示例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,
            })
        )
开发者ID:mreguero,项目名称:don_stephen,代码行数:42,代码来源:views.py

示例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)
开发者ID:sync-for-science,项目名称:test-suite,代码行数:40,代码来源:tasks.py

示例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()
开发者ID:salmon,项目名称:somethingmess,代码行数:16,代码来源:behave_model.py


注:本文中的behave.runner.Runner.run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。