test_step_outside_scenario_or_background_error fails with current gherkin-official
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- testing-qa
Hướng nghiên cứu
Bắt đầu với tests/parser/test_errors.py và chạy các môi trường tox py3.13-pytest8.3-gherkin_officiallatest và py3.13-pytest8.3-gherkin_official30 để so sánh lỗi. Điều tra cách phiên bản gherkin-official hiện tại xử lý step nằm ngoài Scenario hoặc Background, và hoàn tất khi test báo cáo FeatureError như mong đợi với dependency mới nhất và các parser test đều vượt qua.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 1.5k
- Fork
- 251
- Merge trung bình
- 43 phút
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pytest-dev/pytest-bdd
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
pytest-dev/pytest-bdd#805 ·
-
YAML support removed in v8Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
pytest-dev/pytest-bdd#785 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
pytest-dev/pytest-bdd#784 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
pytest-dev/pytest-bdd#782 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
pytest-dev/pytest-bdd#780 · 3 reaction ·
Tất cả issue của pytest-dev/pytest-bdd
Issue tương tự
-
customer-reported
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Azure/azure-cli#34150 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
community-request
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
NVIDIA-NeMo/Curator#2464 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
weblate-discover crashes with an unhandled FileNotFoundError when the directory does not existĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
WeblateOrg/translation-finder#1099 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
trezor/trezor-firmware#7997 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày