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 260b7f2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
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
14 changes: 7 additions & 7 deletions tests/feature/test_cucumber_json.py
Expand Up @@ -125,14 +125,14 @@ def test_passing_outline():
"name": "Passing",
"steps": [
{
"keyword": "Given ",
"keyword": "Given",
"line": 6,
"match": {"location": ""},
"name": "a passing step",
"result": {"status": "passed", "duration": OfType(int)},
},
{
"keyword": "And ",
"keyword": "And",
"line": 7,
"match": {"location": ""},
"name": "some other passing step",
Expand All @@ -150,14 +150,14 @@ def test_passing_outline():
"name": "Failing",
"steps": [
{
"keyword": "Given ",
"keyword": "Given",
"line": 11,
"match": {"location": ""},
"name": "a passing step",
"result": {"status": "passed", "duration": OfType(int)},
},
{
"keyword": "And ",
"keyword": "And",
"line": 12,
"match": {"location": ""},
"name": "a failing step",
Expand All @@ -176,7 +176,7 @@ def test_passing_outline():
"line": 16,
"match": {"location": ""},
"result": {"status": "passed", "duration": OfType(int)},
"keyword": "Given ",
"keyword": "Given",
"name": "type str and value hello",
}
],
Expand All @@ -194,7 +194,7 @@ def test_passing_outline():
"line": 16,
"match": {"location": ""},
"result": {"status": "passed", "duration": OfType(int)},
"keyword": "Given ",
"keyword": "Given",
"name": "type int and value 42",
}
],
Expand All @@ -212,7 +212,7 @@ def test_passing_outline():
"line": 16,
"match": {"location": ""},
"result": {"status": "passed", "duration": OfType(int)},
"keyword": "Given ",
"keyword": "Given",
"name": "type float and value 1.0",
}
],
Expand Down
20 changes: 10 additions & 10 deletions tests/feature/test_report.py
Expand Up @@ -116,15 +116,15 @@ def should_have_left_cucumbers(cucumbers, left):
{
"duration": OfType(float),
"failed": False,
"keyword": "Given ",
"keyword": "Given",
"line_number": 6,
"name": "a passing step",
"type": "given",
},
{
"duration": OfType(float),
"failed": False,
"keyword": "And ",
"keyword": "And",
"line_number": 7,
"name": "some other passing step",
"type": "given",
Expand All @@ -151,15 +151,15 @@ def should_have_left_cucumbers(cucumbers, left):
{
"duration": OfType(float),
"failed": False,
"keyword": "Given ",
"keyword": "Given",
"line_number": 11,
"name": "a passing step",
"type": "given",
},
{
"duration": OfType(float),
"failed": True,
"keyword": "And ",
"keyword": "And",
"line_number": 12,
"name": "a failing step",
"type": "given",
Expand All @@ -185,23 +185,23 @@ def should_have_left_cucumbers(cucumbers, left):
{
"duration": OfType(float),
"failed": False,
"keyword": "Given ",
"keyword": "Given",
"line_number": 15,
"name": "there are 12 cucumbers",
"type": "given",
},
{
"duration": OfType(float),
"failed": False,
"keyword": "When ",
"keyword": "When",
"line_number": 16,
"name": "I eat 5 cucumbers",
"type": "when",
},
{
"duration": OfType(float),
"failed": False,
"keyword": "Then ",
"keyword": "Then",
"line_number": 17,
"name": "I should have 7 cucumbers",
"type": "then",
Expand All @@ -227,23 +227,23 @@ def should_have_left_cucumbers(cucumbers, left):
{
"duration": OfType(float),
"failed": False,
"keyword": "Given ",
"keyword": "Given",
"line_number": 15,
"name": "there are 5 cucumbers",
"type": "given",
},
{
"duration": OfType(float),
"failed": False,
"keyword": "When ",
"keyword": "When",
"line_number": 16,
"name": "I eat 4 cucumbers",
"type": "when",
},
{
"duration": OfType(float),
"failed": False,
"keyword": "Then ",
"keyword": "Then",
"line_number": 17,
"name": "I should have 1 cucumbers",
"type": "then",
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 260b7f2

Please sign in to comment.