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


Python behave.when方法代码示例

本文整理汇总了Python中behave.when方法的典型用法代码示例。如果您正苦于以下问题:Python behave.when方法的具体用法?Python behave.when怎么用?Python behave.when使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在behave的用法示例。


在下文中一共展示了behave.when方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: non_interactive_local_run

# 需要导入模块: import behave [as 别名]
# 或者: from behave import when [as 别名]
def non_interactive_local_run(context, var, val):
    with Path("fake_simple_service"):
        # The local-run invocation here is designed to run and return a sentinel
        # exit code that we can look out for. It also sleeps a few seconds
        # because the local-run code currently crashes when the docker
        # container dies before it gets a chance to lookup the containerid
        # (which causes jenkins flakes) The sleep can be removed once local-run
        # understands that containers can die quickly.
        localrun_cmd = (
            "paasta local-run "
            "--yelpsoa-config-root ../fake_soa_configs_local_run/ "
            "--service fake_simple_service "
            "--cluster test-cluster "
            "--instance main "
            "--build "
            """--cmd '/bin/sh -c "echo \\"%s=$%s\\" && sleep 2s && exit 42"' """
            % (var, var)
        )
        context.return_code, context.output = _run(command=localrun_cmd, timeout=90) 
开发者ID:Yelp,项目名称:paasta,代码行数:21,代码来源:local_run_steps.py

示例2: map_action

# 需要导入模块: import behave [as 别名]
# 或者: from behave import when [as 别名]
def map_action(step_text: str, existing_step_or_steps: Union[str, List[str]]) -> None:
    """
    Map new "given"/"when" steps to one or many existing one(s).
    Parameters are propagated to the original step(s) as well, as expected.

    Examples:

     - map_action('I open door', 'I send event open_door')
     - map_action('Event {name} has to be sent', 'I send event {name}')
     - map_action('I do two things', ['First thing to do', 'Second thing to do'])

    :param step_text: Text of the new step, without the "given" or "when" keyword.
    :param existing_step_or_steps: existing step, without the "given" or "when" keyword. Could be a list of steps.
    """
    if not isinstance(existing_step_or_steps, str):
        existing_step_or_steps = '\nand '.join(existing_step_or_steps)

    @given(step_text)
    def _(context, **kwargs):
        context.execute_steps('Given ' + existing_step_or_steps.format(**kwargs))

    @when(step_text)
    def _(context, **kwargs):
        context.execute_steps('When ' + existing_step_or_steps.format(**kwargs)) 
开发者ID:AlexandreDecan,项目名称:sismic,代码行数:26,代码来源:wrappers.py

示例3: step_impl

# 需要导入模块: import behave [as 别名]
# 或者: from behave import when [as 别名]
def step_impl(context, args):
    cbs = ','.join(context.callbacks)
    context.execute_steps('when we run pgmigrate with ' + '"%s"' %
                          ('-a ' + cbs + ' ' + args, )) 
开发者ID:yandex,项目名称:pgmigrate,代码行数:6,代码来源:callbacks.py

示例4: step_flash_firmware_bytestream_retries

# 需要导入模块: import behave [as 别名]
# 或者: from behave import when [as 别名]
def step_flash_firmware_bytestream_retries(context, retries):
    """Tries to flash the firmware from a bytestream.

    Args:
      context (Context): the ``Context`` instance
      retries (int): the number of retries when flashing

    Returns:
      ``None``
    """
    jlink = context.jlink
    retries = int(retries)
    data = context.data

    while retries >= 0:
        try:
            res = jlink.flash(context.data, 0)
            if res >= 0:
                break
        except pylink.JLinkException as e:
            retries = retries - 1

    assert retries >= 0

    written = list(map(int, jlink.memory_read8(0, len(data))))
    assert written == data 
开发者ID:square,项目名称:pylink,代码行数:28,代码来源:common.py

示例5: step_enable_swo_on_port

# 需要导入模块: import behave [as 别名]
# 或者: from behave import when [as 别名]
def step_enable_swo_on_port(context, port):
    """Enables Serial Wire Output.

    Args:
      context (Context): the ``Context`` instance
      port (int): the port SWO is enabled on

    Returns:
      ``None``
    """
    jlink = context.jlink

    # Have to halt the CPU before getting its speed.
    jlink.reset()
    jlink.halt()
    assert jlink.halted()

    cpu_speed = jlink.cpu_speed()
    swo_speed = jlink.swo_supported_speeds(cpu_speed, 3)[0]

    # Enable SWO and flush.  This must come before the reset to ensure that no
    # data is present in the SWO buffer when the core restarts.
    jlink.swo_start(swo_speed)
    jlink.swo_flush()

    assert jlink.swo_enabled()

    # Reset the core without halting so that it runs.
    jlink.reset(ms=10, halt=False)
    time.sleep(1) 
开发者ID:square,项目名称:pylink,代码行数:32,代码来源:swo.py

示例6: impl

# 需要导入模块: import behave [as 别名]
# 或者: from behave import when [as 别名]
def impl(context):
    context.execute_steps('''
        when I visit the "login" page
        when I enter "standard.user@test.test" into the "username" field
        when I enter "pass" into the "password" field
        when I submit the form
    ''') 
开发者ID:nlhkabu,项目名称:connect,代码行数:9,代码来源:common.py

示例7: impl

# 需要导入模块: import behave [as 别名]
# 或者: from behave import when [as 别名]
def impl(context, tag):
    context.execute_steps("when I select the tag '%s'" % tag)
    context.execute_steps(u'When I open the first mail in the mail list') 
开发者ID:pixelated,项目名称:pixelated-user-agent,代码行数:5,代码来源:mail_list.py

示例8: test_mode_environment_check

# 需要导入模块: import behave [as 别名]
# 或者: from behave import when [as 别名]
def test_mode_environment_check(context):
    """Test that the SIMQLE_MODE env variable switches the connections."""
    # When there is no SIMQLE_MODE set, production mode is used by default
    assert os.getenv("SIMQLE_MODE", None) is None

    production_manager = ConnectionManager()
    production_engine = production_manager.get_engine("my-sqlite-database")
    production_url = str(production_engine.url)

    assert production_url == "sqlite:////tmp/production-database.db"


    # when SIMQLE_MODE is "production", then production mode is active
    os.environ["SIMQLE_MODE"] = "production"

    production_manager = ConnectionManager()
    production_engine = production_manager.get_engine("my-sqlite-database")
    production_url = str(production_engine.url)

    assert production_url == "sqlite:////tmp/production-database.db"


    # when SIMQLE_MODE is "development", then development mode is active
    os.environ["SIMQLE_MODE"] = "development"
    development_manager = ConnectionManager()
    development_engine = development_manager.get_engine("my-sqlite-database")
    development_url = str(development_engine.url)

    assert development_url == "sqlite:////tmp/development-database.db"

    # when SIMQLE_MODE is "testing", then testing mode is active
    os.environ["SIMQLE_MODE"] = "testing"
    development_manager = ConnectionManager()
    development_engine = development_manager.get_engine("my-sqlite-database")
    development_url = str(development_engine.url)

    assert development_url == "sqlite:////tmp/test-database.db"


    # del SIMQLE_MODE for the next test
    del os.environ["SIMQLE_MODE"] 
开发者ID:Harlekuin,项目名称:SimQLe,代码行数:43,代码来源:connection-mode.py

示例9: step_impl

# 需要导入模块: import behave [as 别名]
# 或者: from behave import when [as 别名]
def step_impl(ctx):
    # you should check `actual` when tests fail
    actual = util.read_printable(ctx.pty).splitlines()
    wanted = ctx.text.splitlines()
    expect(actual[-len(wanted):]).to(equal(wanted)) 
开发者ID:d11wtq,项目名称:dockerpty,代码行数:7,代码来源:step_definitions.py


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