當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。