本文整理汇总了Python中lettuce.core.Scenario类的典型用法代码示例。如果您正苦于以下问题:Python Scenario类的具体用法?Python Scenario怎么用?Python Scenario使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Scenario类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_scenario_has_repr
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">'
)
示例2: test_scenario_has_steps
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'},
]
)
示例3: test_scenario_may_own_outlines
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'},
]
)
示例4: test_scenario_has_tag
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'])
示例5: test_scenario_matches_tags_fuzzywuzzy
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'])
示例6: test_scenario_has_tag
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'])
示例7: test_scenario_with_inline_comments
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')
示例8: test_scenario_matches_tags_excluding_when_scenario_has_no_tags
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'])
示例9: test_scenario_matches_tags_excluding_fuzzywuzzy
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'])
示例10: test_scenario_tables_are_solved_against_outlines
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)
示例11: test_scenario_show_tags_in_its_representation
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')
示例12: test_scenario_ignore_commented_lines_from_examples
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'},
]
)
示例13: test_scenario_matches_tags
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'])
示例14: test_scenario_has_name
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"
)
示例15: test_scenario_show_tags_in_its_representation
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')