Skip to content

Commit 1f0a2e7

Browse files
author
Ludovic CHAPELET
committed
tests: removed tests for step outside scenario
1 parent 04d1980 commit 1f0a2e7

File tree

2 files changed

+0
-43
lines changed

2 files changed

+0
-43
lines changed

src/pytest_bdd/gherkin_parser.py

-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@
2323
exceptions.FeatureError,
2424
"Multiple features are not allowed in a single feature file.",
2525
),
26-
(
27-
re.compile(r"expected:.*got '(?:Given|When|Then|And|But).*'"),
28-
exceptions.FeatureError,
29-
"Step definition outside of a Scenario or a Background.",
30-
),
3126
(
3227
re.compile(r"expected:.*got 'Background.*'"),
3328
exceptions.BackgroundError,

tests/parser/test_errors.py

-38
Original file line numberDiff line numberDiff line change
@@ -34,44 +34,6 @@ def test_multiple_features_error(pytester):
3434
result.stdout.fnmatch_lines(["*FeatureError: Multiple features are not allowed in a single feature file.*"])
3535

3636

37-
def test_step_outside_scenario_or_background_error(pytester):
38-
"""Test step outside of a Scenario or Background."""
39-
features = pytester.mkdir("features")
40-
features.joinpath("test.feature").write_text(
41-
textwrap.dedent(
42-
"""
43-
Feature: Invalid Feature
44-
# Step not inside a scenario or background
45-
Given a step that is not inside a scenario or background
46-
47-
Scenario: A valid scenario
48-
Given a step inside a scenario
49-
50-
"""
51-
),
52-
encoding="utf-8",
53-
)
54-
55-
pytester.makepyfile(
56-
textwrap.dedent(
57-
"""
58-
from pytest_bdd import scenarios, given
59-
60-
@given("a step inside a scenario")
61-
def step_inside_scenario():
62-
pass
63-
64-
scenarios('features')
65-
"""
66-
)
67-
)
68-
69-
result = pytester.runpytest()
70-
71-
# Expect the FeatureError for the step outside of scenario or background
72-
result.stdout.fnmatch_lines(["*FeatureError: Step definition outside of a Scenario or a Background.*"])
73-
74-
7537
def test_multiple_backgrounds_error(pytester):
7638
"""Test multiple backgrounds in a single feature."""
7739
features = pytester.mkdir("features")

0 commit comments

Comments
 (0)