YAML support removed in v8
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 30/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Cần làm rõ
- 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 bằng cách kiểm tra pytest_bdd/gherkin_parser.py quanh dòng 316 và tái hiện CompositeParserException đã báo cáo với một feature chứa phần thân step có dạng giống YAML. Đọc hành vi của trình phân tích cú pháp Gherkin bên dưới và xác định một cú pháp cụ thể cùng phạm vi phân tích cú pháp có thể bảo toàn các biến Gherkin. Công việc được xem là hoàn tất khi cú pháp được chọn phân tích thành công và hỗ trợ các kiểu tham số tùy chỉnh cho dữ liệu step có cấu trúc.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Context
In previous versions of pytest-bdd, it was possible to define steps that included inline YAML-like syntax, which made it much easier to write complex or parameterized tests. For example:
Given a new resource with:
id: 1234
name: new resource
data: any-data
and then parse those parameters using a custom parser:
@given(parsers.cfparse(
'a new resource with:\n{resource_parameters:yaml}',
extra_types={"yaml": yaml.safe_load}
))
def _(resource_parameters):
id = resource_parameters["id"]
# test code
Current Problem
Since version 8 of pytest-bdd, it seems that changes introduced in the underlying Gherkin parser (via gherkin-official) have made this syntax invalid.
Running tests written this way now produces the following parser error:
.venv/lib/python3.10/site-packages/pytest_bdd/gherkin_parser.py:316: in get_gherkin_document
gherkin_data = Parser().parse(feature_file_text)
.venv/lib/python3.10/site-packages/gherkin/parser.py:79: in parse
state = self.match_token(state, token, context)
.venv/lib/python3.10/site-packages/gherkin/parser.py:222: in match_token
return state_map[state](token, context)
.venv/lib/python3.10/site-packages/gherkin/parser.py:1104: in match_token_at_15
self.add_error(context, error)
.venv/lib/python3.10/site-packages/gherkin/parser.py:97: in add_error
raise CompositeParserException(context.errors)
E gherkin.errors.CompositeParserException: Parser errors:
E (9:13): expected: #EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty, got 'id: 1234'
Expected Behavior / Feature Proposal
It would be extremely helpful to support YAML-like syntax blocks inside Gherkin steps again — either through:
Allowing indentation-based content as a valid part of a step body,
Or by supporting a new syntax (e.g., fenced blocks or docstrings with a yaml type hint) that can be parsed using custom parameter types.
This feature would allow writing structured input directly in .feature files, while still enabling parameterization via Gherkin variables.
Motivation
YAML-style parameter blocks make test scenarios much more readable and maintainable, especially when working with APIs or data-rich test cases.
This capability was previously possible using cfparse with custom extra_types, and restoring it (or providing an alternative) would improve developer ergonomics significantly.
It would be important that any future implementation of this feature continues to support the use of Gherkin variables inside the YAML-like syntax, as this was previously a key advantage for writing parameterized and data-driven tests directly in feature files:
Given a new resource with:
id: <id>
Examples:
| id |
Thank you in advance
- Ngôn ngữ chính
- Python
- Star
- 1.5k
- Fork
- 253
- Merge trung bình
- 4 giờ 30 phút
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
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
-
New release to update `gherkin`?Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
pytest-dev/pytest-bdd#838 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
pytest-dev/pytest-bdd#805 ·
-
Độ 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 ·
-
Tests with failing setup fixture should get the "Error" statusCó thể đã có người làm @zvarych-oleksii đã nhận 4 ngày trước. Đang mở
Độ 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 · 1 bình luận ·
-
Độ 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 · 5 reaction ·
Tất cả issue của pytest-dev/pytest-bdd
Issue tương tự
-
bug P1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Toloka/tolokaforge#1947 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
SageMaker provider: streaming fails with NoStreamDataError on DJL Serving (LMI) endpointsCó thể đã có người làm @balajiaru đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
UKGovernmentBEIS/inspect_ai#6127 ·
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 67/100
pydot/pydot#601 · 4 bình luận ·
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 68/100
letsencrypt/cp-cps#361 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100