-
Notifications
You must be signed in to change notification settings - Fork 228
Open
Description
Describe the bug
With the current gherkin-official
(now 32.1.2), test_step_outside_scenario_or_background_error
fails.
To Reproduce
Write a Minimal, Reproducible Example to show the bug.
$ git clone https://github.com/pytest-dev/pytest-bdd.git
$ cd pytest-bdd
$ tox -e py3.13-pytest8.3-gherkin_officiallatest
[…]
============================================== FAILURES ==============================================
___________________________ test_step_outside_scenario_or_background_error ___________________________
pytester = <Pytester PosixPath('/tmp/pytest-of-ben/pytest-19/test_step_outside_scenario_or_background_error0')>
def test_step_outside_scenario_or_background_error(pytester):
"""Test step outside of a Scenario or Background."""
features = pytester.mkdir("features")
features.joinpath("test.feature").write_text(
textwrap.dedent(
"""
Feature: Invalid Feature
# Step not inside a scenario or background
Given a step that is not inside a scenario or background
Scenario: A valid scenario
Given a step inside a scenario
"""
),
encoding="utf-8",
)
pytester.makepyfile(
textwrap.dedent(
"""
from pytest_bdd import scenarios, given
@given("a step inside a scenario")
def step_inside_scenario():
pass
scenarios('features')
"""
)
)
result = pytester.runpytest()
# Expect the FeatureError for the step outside of scenario or background
> result.stdout.fnmatch_lines(["*FeatureError: Step definition outside of a Scenario or a Background.*"])
E Failed: nomatch: '*FeatureError: Step definition outside of a Scenario or a Background.*'
E and: '======================================== test session starts ========================================='
E and: 'platform linux -- Python 3.13.3, pytest-8.4.1, pluggy-1.6.0'
E and: 'rootdir: /tmp/pytest-of-ben/pytest-19/test_step_outside_scenario_or_background_error0'
E and: 'plugins: bdd-8.1.0'
E and: 'collected 1 item'
E and: ''
E and: 'test_step_outside_scenario_or_background_error.py . [100%]'
E and: ''
E and: '========================================= 1 passed in 0.01s =========================================='
E remains unmatched: '*FeatureError: Step definition outside of a Scenario or a Background.*'
features = PosixPath('/tmp/pytest-of-ben/pytest-19/test_step_outside_scenario_or_background_error0/features')
pytester = <Pytester PosixPath('/tmp/pytest-of-ben/pytest-19/test_step_outside_scenario_or_background_error0')>
result = <RunResult ret=0 len(stdout.lines)=9 len(stderr.lines)=0 duration=0.02s>
/home/ben/src/forks/pytest-bdd/tests/parser/test_errors.py:72: Failed
---------------------------------------- Captured stdout call ----------------------------------------
======================================== test session starts =========================================
platform linux -- Python 3.13.3, pytest-8.4.1, pluggy-1.6.0
rootdir: /tmp/pytest-of-ben/pytest-19/test_step_outside_scenario_or_background_error0
plugins: bdd-8.1.0
collected 1 item
test_step_outside_scenario_or_background_error.py . [100%]
========================================= 1 passed in 0.01s ==========================================
====================================== short test summary info =======================================
FAILED tests/parser/test_errors.py::test_step_outside_scenario_or_background_error - Failed: nomatch: '*FeatureError: Step definition outside of a Scenario or a Background.*'
and: '======================================== test session starts ========================================='
and: 'platform linux -- Python 3.13.3, pytest-8.4.1, pluggy-1.6.0'
and: 'rootdir: /tmp/pytest-of-ben/pytest-19/test_step_outside_scenario_or_background_error0'
and: 'plugins: bdd-8.1.0'
and: 'collected 1 item'
and: ''
and: 'test_step_outside_scenario_or_background_error.py . [100%]'
and: ''
and: '========================================= 1 passed in 0.01s =========================================='
remains unmatched: '*FeatureError: Step definition outside of a Scenario or a Background.*'
============================= 1 failed, 137 passed, 1 skipped in 10.76s ==============================
Expected behavior
Compare to:
$ tox -e py3.13-pytest8.3-gherkin_official30
[…]
================================== 138 passed, 1 skipped in 10.87s ===================================
Additional context
N/A
Version
- pytest version: 8.3
- pytest-bdd version:
master
(01c99a6); also observed in 8.1.0 - OS: Fedora 42,
x86_64
Metadata
Metadata
Assignees
Labels
No labels