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


Python Scenario.from_string方法代码示例

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


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

示例1: test_scenario_has_repr

# 需要导入模块: from lettuce.core import Scenario [as 别名]
# 或者: from lettuce.core.Scenario import from_string [as 别名]
def test_scenario_has_repr():
    "Scenario implements __repr__ nicely"
    scenario = Scenario.from_string(SCENARIO1)
    assert_equals(
        repr(scenario),
        '<Scenario: "Adding some students to my university database">'
    )
开发者ID:EthanGuo,项目名称:lettuce,代码行数:9,代码来源:test_scenario_parsing.py

示例2: test_scenario_has_steps

# 需要导入模块: from lettuce.core import Scenario [as 别名]
# 或者: from lettuce.core.Scenario import from_string [as 别名]
def test_scenario_has_steps():
    "A scenario object should have a list of steps"

    scenario = Scenario.from_string(SCENARIO1)

    assert_equals(type(scenario.steps), list)
    assert_equals(len(scenario.steps), 4, "It should have 4 steps")

    expected_sentences = [
        "Given I have the following courses in my university:",
        "When I consolidate the database into 'courses.txt'",
        "Then I see the 1st line of 'courses.txt' has 'Computer Science:5'",
        "And I see the 2nd line of 'courses.txt' has 'Nutrition:4'",
    ]

    for step, expected_sentence in zip(scenario.steps, expected_sentences):
        assert_equals(type(step), Step)
        assert_equals(step.sentence, expected_sentence)

    assert_equals(scenario.steps[0].keys, ('Name', 'Duration'))
    assert_equals(
        scenario.steps[0].hashes,
        [
            {'Name': 'Computer Science', 'Duration': '5 years'},
            {'Name': 'Nutrition', 'Duration': '4 years'},
        ]
    )
开发者ID:EthanGuo,项目名称:lettuce,代码行数:29,代码来源:test_scenario_parsing.py

示例3: test_scenario_may_own_outlines

# 需要导入模块: from lettuce.core import Scenario [as 别名]
# 或者: from lettuce.core.Scenario import from_string [as 别名]
def test_scenario_may_own_outlines():
    "A scenario may own outlines"
    scenario = Scenario.from_string(OUTLINED_SCENARIO)

    assert_equals(len(scenario.steps), 4)
    expected_sentences = [
        'Given I have entered <input_1> into the calculator',
        'And I have entered <input_2> into the calculator',
        'When I press <button>',
        'Then the result should be <output> on the screen',
    ]

    for step, expected_sentence in zip(scenario.steps, expected_sentences):
        assert_equals(type(step), Step)
        assert_equals(step.sentence, expected_sentence)

    assert_equals(scenario.name, "Add two numbers")
    assert_equals(
        scenario.outlines,
        [
            {'input_1': '20', 'input_2': '30', 'button': 'add', 'output': '50'},
            {'input_1': '2', 'input_2': '5', 'button': 'add', 'output': '7'},
            {'input_1': '0', 'input_2': '40', 'button': 'add', 'output': '40'},
        ]
    )
开发者ID:EthanGuo,项目名称:lettuce,代码行数:27,代码来源:test_scenario_parsing.py

示例4: test_scenario_has_tag

# 需要导入模块: from lettuce.core import Scenario [as 别名]
# 或者: from lettuce.core.Scenario import from_string [as 别名]
def test_scenario_has_tag():
    "A scenario object should be able to find at least one tag " \
       "on the first line"

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=('@onetag\n' + SCENARIO1.strip()))

    assert that(scenario.tags).deep_equals(['onetag'])
开发者ID:UjeenM,项目名称:lettuce,代码行数:11,代码来源:test_scenario_parsing.py

示例5: test_scenario_matches_tags_fuzzywuzzy

# 需要导入模块: from lettuce.core import Scenario [as 别名]
# 或者: from lettuce.core.Scenario import from_string [as 别名]
def test_scenario_matches_tags_fuzzywuzzy():
    ("When Scenario#matches_tags is called with a member starting with ~ "
     "it will consider a fuzzywuzzy match")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=('@anothertag\[email protected]\n' + SCENARIO1.strip()))

    assert scenario.matches_tags(['~another'])
开发者ID:UjeenM,项目名称:lettuce,代码行数:11,代码来源:test_scenario_parsing.py

示例6: test_scenario_has_tag

# 需要导入模块: from lettuce.core import Scenario [as 别名]
# 或者: from lettuce.core.Scenario import from_string [as 别名]
def test_scenario_has_tag():
    ("A scenario object should be able to find at least one tag "
     "on the first line")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=('@onetag\n' + SCENARIO1.strip()))

    expect(scenario.tags).to.equal(['onetag'])
开发者ID:Bunch,项目名称:lettuce,代码行数:11,代码来源:test_scenario_parsing.py

示例7: test_scenario_with_inline_comments

# 需要导入模块: from lettuce.core import Scenario [as 别名]
# 或者: from lettuce.core.Scenario import from_string [as 别名]
def test_scenario_with_inline_comments():
    ("Scenarios can have steps with inline comments")

    scenario = Scenario.from_string(INLINE_COMMENTS)

    step1, step2 = scenario.steps

    expect(step1.sentence).to.equal(u'Given I am using an anvil')
    expect(step2.sentence).to.equal(u'And I am using a hammer')
开发者ID:EthanGuo,项目名称:lettuce,代码行数:11,代码来源:test_scenario_parsing.py

示例8: test_scenario_matches_tags_excluding_when_scenario_has_no_tags

# 需要导入模块: from lettuce.core import Scenario [as 别名]
# 或者: from lettuce.core.Scenario import from_string [as 别名]
def test_scenario_matches_tags_excluding_when_scenario_has_no_tags():
    ("When Scenario#matches_tags is called for a scenario "
     "that has no tags and the given match is a exclusionary tag")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=(SCENARIO1.strip()))

    assert scenario.matches_tags(['-nope', '-neither'])
开发者ID:EthanGuo,项目名称:lettuce,代码行数:11,代码来源:test_scenario_parsing.py

示例9: test_scenario_matches_tags_excluding_fuzzywuzzy

# 需要导入模块: from lettuce.core import Scenario [as 别名]
# 或者: from lettuce.core.Scenario import from_string [as 别名]
def test_scenario_matches_tags_excluding_fuzzywuzzy():
    ("When Scenario#matches_tags is called with a member starting with -~ "
     "it will exclude that tag from that fuzzywuzzy match")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=('@anothertag\[email protected]\n' + SCENARIO1.strip()))

    assert not scenario.matches_tags(['-~anothertag'])
开发者ID:EthanGuo,项目名称:lettuce,代码行数:11,代码来源:test_scenario_parsing.py

示例10: test_scenario_tables_are_solved_against_outlines

# 需要导入模块: from lettuce.core import Scenario [as 别名]
# 或者: from lettuce.core.Scenario import from_string [as 别名]
def test_scenario_tables_are_solved_against_outlines():
    "Outline substitution should apply to multiline strings within a scenario"
    expected_multiline = '<div>outline value</div>'

    scenario = Scenario.from_string(OUTLINED_SCENARIO_WITH_SUBSTITUTIONS_IN_MULTILINE)
    step = scenario.solved_steps[0]
    
    assert_equals(type(step), Step)
    assert_equals(step.multiline, expected_multiline)
开发者ID:adw0rd,项目名称:lettuce-py3,代码行数:11,代码来源:test_scenario_parsing.py

示例11: test_scenario_show_tags_in_its_representation

# 需要导入模块: from lettuce.core import Scenario [as 别名]
# 或者: from lettuce.core.Scenario import from_string [as 别名]
def test_scenario_show_tags_in_its_representation():
    ("Scenario#represented should show its tags")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=('@slow\[email protected]\[email protected]\n' + SCENARIO1.strip()))

    assert that(scenario.represented()).equals(
        u'  @slow @firefox @chrome\n  '
        'Scenario: Adding some students to my university database')
开发者ID:UjeenM,项目名称:lettuce,代码行数:12,代码来源:test_scenario_parsing.py

示例12: test_scenario_ignore_commented_lines_from_examples

# 需要导入模块: from lettuce.core import Scenario [as 别名]
# 或者: from lettuce.core.Scenario import from_string [as 别名]
def test_scenario_ignore_commented_lines_from_examples():
    "Comments on scenario example should be ignored"
    scenario = Scenario.from_string(OUTLINED_SCENARIO_WITH_COMMENTS_ON_EXAMPLES)

    assert_equals(
        scenario.outlines,
        [
            {'input_1': '20', 'input_2': '30', 'button': 'add', 'output': '50'},
            {'input_1': '0', 'input_2': '40', 'button': 'add', 'output': '40'},
        ]
    )
开发者ID:EthanGuo,项目名称:lettuce,代码行数:13,代码来源:test_scenario_parsing.py

示例13: test_scenario_matches_tags

# 需要导入模块: from lettuce.core import Scenario [as 别名]
# 或者: from lettuce.core.Scenario import from_string [as 别名]
def test_scenario_matches_tags():
    ("A scenario with tags should respond with True when "
     ".matches_tags() is called with a valid list of tags")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=('@onetag\[email protected]\n' + SCENARIO1.strip()))

    assert that(scenario.tags).deep_equals(['onetag','another-one'])
    assert scenario.matches_tags(['onetag'])
    assert scenario.matches_tags(['another-one'])
开发者ID:UjeenM,项目名称:lettuce,代码行数:13,代码来源:test_scenario_parsing.py

示例14: test_scenario_has_name

# 需要导入模块: from lettuce.core import Scenario [as 别名]
# 或者: from lettuce.core.Scenario import from_string [as 别名]
def test_scenario_has_name():
    "It should extract the name of the scenario"

    scenario = Scenario.from_string(SCENARIO1)

    assert isinstance(scenario, Scenario)

    assert_equals(
        scenario.name,
        "Adding some students to my university database"
    )
开发者ID:EthanGuo,项目名称:lettuce,代码行数:13,代码来源:test_scenario_parsing.py

示例15: test_scenario_show_tags_in_its_representation

# 需要导入模块: from lettuce.core import Scenario [as 别名]
# 或者: from lettuce.core.Scenario import from_string [as 别名]
def test_scenario_show_tags_in_its_representation():
    ("Scenario#represented should show its tags")

    scenario = Scenario.from_string(
        SCENARIO1,
        original_string=SCENARIO1.strip(),
        tags=['slow', 'firefox', 'chrome'])

    expect(scenario.represented()).to.equal(
        u'  @slow @firefox @chrome\n  '
        'Scenario: Adding some students to my university database')
开发者ID:EthanGuo,项目名称:lettuce,代码行数:13,代码来源:test_scenario_parsing.py


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