Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Rewrite pytest-bdd to use hooks and marks

Đang mở
#310 8 bình luận 3 reaction 0 người được giao Xem trên GitHub

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
25/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
testing

Hướng nghiên cứu

Bắt đầu bằng cách đọc issue #296 và tài liệu pytest được liên kết về marks và hooks, sau đó so sánh API được đề xuất với các decorator pytest-bdd hiện tại được nêu trong issue. Xác định xem bản viết lại có thể giữ nguyên các tính năng hiện có hay không và quyết định vai trò của mark @scenario; công việc được xem là hoàn tất khi có một thiết kế và kế hoạch triển khai đã được thống nhất.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Following the suggestion from issue #296, I will try to re-implement pytest-bdd to use marks and hooks.

I imagine an API that will look like this:

# test_some_scenario.py
pytestmark = pytest.mark.scenarios('a.feature')

# override "Scenario 3"
@pytest.mark.scenario('a.feature', 'Scenario 3')
def test_a_scenario(...):
    # do something more
    pass

instead of the current way:

import pytest_bdd

# override "Scenario 3"
@pytest_bdd.scenario('a.feature', 'Scenario 3')
def test_a_scenario(...):
    # do something more
    pass

scenarios('a.feature')

I yet don't know if this is entirely feasible without breaking other features, but we will see.

Short note about @scenario(...)

Potentially, I will also remove the single scenario mark/decorator, given that the only thing it allows to do is to require some more fixtures before the scenario is run, and to execute some more logic after the scenario finished.
This custom logic can already be implemented using given and then steps, but I understand that sometimes it can be just some compensation logic that should not appear in the feature file.
I still didn't figure out what to do with this, so probably I'll keep the @scenario mark/decorator for the time being.

@bubenkoff @olegpidsadnyi @sliwinski-milosz: Feedback on this idea would be appreciated.

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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của pytest-dev/pytest-bdd

Tất cả issue của pytest-dev/pytest-bdd

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.