Skip to content

Commit

Permalink
Keyword should be without trailing spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
youtux committed Mar 11, 2022
1 parent 99b61fd commit d594d93
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pytest_bdd/cucumber_json.py
Expand Up @@ -105,7 +105,7 @@ def stepmap(step: dict[str, Any]) -> dict[str, Any]:
step_name = step["name"]

return {
"keyword": step["keyword"],
"keyword": step["keyword"] + " ",
"name": step_name,
"line": step["line_number"],
"match": {"location": ""},
Expand Down
2 changes: 1 addition & 1 deletion pytest_bdd/new_parser.py
Expand Up @@ -100,7 +100,7 @@ def steps(self, step_groups: list[tuple[str, list[Tree]]]) -> list[Step]:
type=bdd_type,
line_number=type_token.line,
indent=type_token.column,
keyword=str(type_token),
keyword=str(type_token.strip()),
)
for bdd_type, [type_token, value_token] in steps_data
]
Expand Down
24 changes: 12 additions & 12 deletions tests/test_new_parser.py
Expand Up @@ -186,23 +186,23 @@ def test_scenario(src, expected_scenarios):
Scenario: a scenario
Given there is a foo
""",
[Step(GIVEN, "there is a foo", 3, 9, "Given ")],
[Step(GIVEN, "there is a foo", 3, 9, "Given")],
),
(
"""\
Feature: a feature
Scenario: a scenario
When I click the foo
""",
[Step(WHEN, "I click the foo", 3, 9, "When ")],
[Step(WHEN, "I click the foo", 3, 9, "When")],
),
(
"""\
Feature: a feature
Scenario: a scenario
Then I should see a foo
""",
[Step(THEN, "I should see a foo", 3, 9, "Then ")],
[Step(THEN, "I should see a foo", 3, 9, "Then")],
),
(
"""\
Expand All @@ -213,9 +213,9 @@ def test_scenario(src, expected_scenarios):
Then I should see a foo
""",
[
Step(GIVEN, "there is a foo", 3, 9, "Given "),
Step(WHEN, "I click the foo", 4, 9, "When "),
Step(THEN, "I should see a foo", 5, 9, "Then "),
Step(GIVEN, "there is a foo", 3, 9, "Given"),
Step(WHEN, "I click the foo", 4, 9, "When"),
Step(THEN, "I should see a foo", 5, 9, "Then"),
],
),
(
Expand All @@ -229,11 +229,11 @@ def test_scenario(src, expected_scenarios):
But I should not see more than one foo
""",
[
Step(GIVEN, "there is a foo", 3, 9, "Given "),
Step(GIVEN, "there is a second foo", 4, 9, "Given "),
Step(GIVEN, "there is a third foo", 5, 9, "And "),
Step(THEN, "I should see a foo", 6, 9, "Then "),
Step(THEN, "I should not see more than one foo", 7, 9, "But "),
Step(GIVEN, "there is a foo", 3, 9, "Given"),
Step(GIVEN, "there is a second foo", 4, 9, "Given"),
Step(GIVEN, "there is a third foo", 5, 9, "And"),
Step(THEN, "I should see a foo", 6, 9, "Then"),
Step(THEN, "I should not see more than one foo", 7, 9, "But"),
],
),
pytest.param(
Expand All @@ -242,7 +242,7 @@ def test_scenario(src, expected_scenarios):
Scenario: a scenario
When I click the foo""",
[
Step(WHEN, "I click the foo", 3, 9, "When "),
Step(WHEN, "I click the foo", 3, 9, "When"),
],
id="no_ending_newline",
),
Expand Down

0 comments on commit d594d93

Please sign in to comment.