test_step_outside_scenario_or_background_error fails with current gherkin-official
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- testing-qa
Direzione di ricerca
Inizia con tests/parser/test_errors.py ed esegui gli ambienti tox py3.13-pytest8.3-gherkin_officiallatest e py3.13-pytest8.3-gherkin_official30 per confrontare il fallimento. Indaga su come la versione corrente di gherkin-official gestisce lo step al di fuori di uno Scenario o Background e termina quando il test segnala il FeatureError previsto con la dipendenza più recente e i test del parser passano.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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(01c99a6693f9023023fe1c1c7373fa88559c4dec); also observed in 8.1.0 - OS: Fedora 42,
x86_64
- Lingua principale
- Python
- Stelle
- 1.5k
- Fork
- 251
- Merge medio
- 43m
- PR unite (30g)
- 2
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pytest-dev/pytest-bdd
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
pytest-dev/pytest-bdd#805 ·
-
YAML support removed in v8Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
pytest-dev/pytest-bdd#785 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
pytest-dev/pytest-bdd#784 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
pytest-dev/pytest-bdd#782 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
pytest-dev/pytest-bdd#780 · 3 reazioni ·
Tutte le issue di pytest-dev/pytest-bdd
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-2 giorni Idoneità per principianti 70/100
-
FingerprintSplitter raises ZeroDivisionError when int(frac_train * len(dataset)) floors to zeroAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 7 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
lmstudio-ai/mlx-engine#376 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
pyiron/bagofholding#166 ·