Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Scenario Outline: Doing all sorts of stuff
Given we have
When we do stuff
Then we have
Examples: Some stuff
| Stuff | Things |
| wool | felt |
| cotton | thread |
Examples: Some other stuff
| Stuff | Things |
| wood | paper |
| explosives | hilarity |
'''.lstrip()
feature = parser.parse_feature(doc)
assert feature.name == "Stuff"
assert len(feature.scenarios) == 1
assert feature.scenarios[0].name == "Doing all sorts of stuff"
assert_compare_steps(feature.scenarios[0].steps, [
('given', 'Given', 'we have ', None, None),
('when', 'When', 'we do stuff', None, None),
('then', 'Then', 'we have ', None, None),
])
table = model.Table(
[u'Stuff', u'Things'],
0,
[
[u'wool', u'felt'],
[u'cotton', u'thread'],
When step uses ""
Examples:
| name | param2 |
| Alice | 1 |
| Bob | 2 |
Scenario Outline: R5.ScenarioOutline_2
Given step with name ""
Examples:
| name |
| Charly |
| Dorothy |
'''.lstrip()
feature = parse_feature(text)
rule1 = feature.rules[0]
rule1_scenario1 = rule1.scenarios[0]
rule1_scenario2 = rule1.scenarios[1]
assert feature.name == "With Rule"
assert feature.background is None
assert len(feature.rules) == 1
assert len(feature.scenarios) == 0
assert rule1.name == "R5"
assert rule1.description == []
assert rule1.tags == []
assert rule1.background is None
assert len(rule1.scenarios) == 2
assert len(rule1_scenario1.scenarios) == 2
assert rule1_scenario1.scenarios[0].name == "R5.ScenarioOutline_1 -- @1.1 "
def test_language_comment_wins_over_commandline(self):
doc = u"""
# language: fr
Fonctionnalit\xe9: testing stuff
Oh my god, it's full of stuff...
"""
feature = parser.parse_feature(doc, language="de")
assert feature.name == "testing stuff"
assert feature.description == ["Oh my god, it's full of stuff..."]
def test_parses_lowercase_step_keywords(self):
doc = u"""
Feature: Stuff
Scenario: Doing stuff
giVeN there is stuff
when I do stuff
tHEn stuff happens
""".lstrip()
feature = parser.parse_feature(doc)
assert feature.name == "Stuff"
assert len(feature.scenarios) == 1
assert feature.scenarios[0].name == "Doing stuff"
assert_compare_steps(feature.scenarios[0].steps, [
('given', 'Given', 'there is stuff', None, None),
('when', 'When', 'I do stuff', None, None),
('then', 'Then', 'stuff happens', None, None),
])
Given you're all stuffed
Scenario: Doing stuff
Given there is stuff
When I do stuff
Then stuff happens
Scenario: Doing other stuff
When stuff happens
Then I am stuffed
Scenario: Doing different stuff
Given stuff
Then who gives a stuff
""".lstrip()
feature = parser.parse_feature(doc)
assert feature.name == "Stuff"
assert feature.description, ["Stuffing"]
assert feature.background
assert_compare_steps(feature.background.steps, [
('given', 'Given', "you're all stuffed", None, None)
])
assert len(feature.scenarios) == 3
assert feature.scenarios[0].name == "Doing stuff"
assert_compare_steps(feature.scenarios[0].steps, [
('given', 'Given', 'there is stuff', None, None),
('when', 'When', 'I do stuff', None, None),
('then', 'Then', 'stuff happens', None, None),
])
def test_whitespace_in_the_language_comment_is_flexible_2(self):
doc = u"""
# language:de
Funktionalit\xe4t: testing stuff
Oh my god, it's full of stuff...
"""
feature = parser.parse_feature(doc)
assert feature.name == "testing stuff"
assert feature.description == ["Oh my god, it's full of stuff..."]
def test_parse__rule_scenarios_without_rule_background_when_background_inheritance_is_disabled_without(self):
# -- HINT: Background inheritance is enabled (by default).
text = u'''
Feature: With Feature Background Inheritance disabled
Background: Feature.Background
Given feature background step_1
@fixture.behave.override_background
Rule: R1
Scenario: R1.Scenario_1
Given rule R1 scenario_1 step_1
'''.lstrip()
feature = parse_feature(text)
assert feature.name == "With Feature Background Inheritance disabled"
assert feature.background is not None
assert len(feature.scenarios) == 0
assert len(feature.rules) == 1
assert len(feature.run_items) == 1
rule1 = feature.rules[0]
rule1_scenario1 = rule1.scenarios[0]
assert feature.run_items == [rule1]
rule1.use_background_inheritance = False # FIXTURE-EFFECT (simulated)
assert rule1.background is not None
assert rule1.background.use_inheritance is False
assert rule1.background is not feature.background
assert rule1.background.inherited_steps == []
def test_parse__norule_scenarios_use_feature_background(self):
"""AFFECTED: Scenarios outside of rules (before first rule)."""
text = u'''
Feature: With Scenarios and Rules
Background: Feature.Background
Given feature background step_1
Scenario: Scenario_1
Given scenario_1 step_1
Rule: R1
Scenario: R1.Scenario_1
Given rule R1 scenario_1 step_1
'''.lstrip()
feature = parse_feature(text)
assert feature.name == "With Scenarios and Rules"
assert feature.background is not None
assert len(feature.scenarios) == 1
assert len(feature.rules) == 1
assert len(feature.run_items) == 2
scenario1 = feature.scenarios[0]
rule1 = feature.rules[0]
assert feature.run_items == [scenario1, rule1]
assert scenario1.name == "Scenario_1"
assert scenario1.background is feature.background
assert scenario1.background_steps == feature.background.steps
assert_compare_steps(scenario1.all_steps, [
(u"given", u"Given", u'feature background step_1', None, None),
(u"given", u"Given", u'scenario_1 step_1', None, None),
def test_parse__rule_scenarios_inherit_feature_background_without_rule_background(self):
text = u'''
Feature: With Background and Rule
Background: Feature.Background
Given feature background step_1
Rule: R1
Scenario: R1.Scenario_1
Given rule R1 scenario_1 step_1
'''.lstrip()
feature = parse_feature(text)
assert feature.name == "With Background and Rule"
assert feature.background is not None
assert len(feature.scenarios) == 0
assert len(feature.rules) == 1
assert len(feature.run_items) == 1
rule1 = feature.rules[0]
rule1_scenario1 = rule1.scenarios[0]
assert feature.run_items == [rule1]
assert rule1_scenario1.name == "R1.Scenario_1"
assert rule1_scenario1.background is not None
# assert rule1_scenario1.background is not feature.background
assert rule1_scenario1.background_steps == feature.background.steps
assert_compare_steps(rule1_scenario1.all_steps, [
(u"given", u"Given", u'feature background step_1', None, None),
doc = u'''
Feature: Background
A feature description line 1.
A feature description line 2.
Background: One
A background description line 1.
A background description line 2.
Given we init stuff
When we init more stuff
Scenario: One
'''.lstrip()
feature = parser.parse_feature(doc)
assert feature.name == "Background"
assert feature.description == [
"A feature description line 1.",
"A feature description line 2.",
]
assert feature.background is not None
assert feature.background.name == "One"
assert feature.background.description == [
"A background description line 1.",
"A background description line 2.",
]
assert_compare_steps(feature.background.steps, [
('given', 'Given', 'we init stuff', None, None),
('when', 'When', 'we init more stuff', None, None),
])