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

Implement parametrization through excel sheets based on the input arguments

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

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
data, testing

Hướng nghiên cứu

Bắt đầu bằng việc xem xét các hook conftest.py được đề xuất, đặc biệt là pytest_addoption và pytest_generate_tests, cùng với đường dẫn Excel iban/data/Licenses.xlsx. Làm rõ liệu --env nên chọn một sheet hay mỗi scenario nên được chạy trên qa, uat và prod; hoàn tất khi việc chọn environment dự kiến hoạt động với scenario được tham số hóa đã nêu.

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

Mô tả

My Scenario is parameterized and I want to select the parameter value from EXCEL. I want to select sheets in the excel based on environment provided qa,uat,prod .Is there any way to dynamically select sheet value to run the parameterised tests.

Scenario: Verify Licenses
    Given the <user> is logged in with <password>
    Then the response should show  <status>

Referring to the issue @ https://github.com/pytest-dev/pytest/issues/6374, I have added the following

In conftest.py

def pytest_addoption(parser):
    parser.addoption('--env',
                     dest='testenv',
                     choices=["qa","uat","prod"],
                     default='qa',
                     help='Specify environment:"qa", "uat", "prod"')


@lru_cache(maxsize = 128)
def get_env(env):
            wbinput = openpyxl.load_workbook('iban/data/Licenses.xlsx')
            sheetip= wbinput[env] # sheet to select based on env
            maxRow=sheetip.max_row
            inputData = [tuple(sheetip.cell(row=i,column=j).value for j in range(1,3)) for i in range(2,maxRow+1)]
    return inputData

# this code doesnot suite me, as I have no markers for my scenario. My scenario should run for all env values but take the correponding env value for each env.
def pytest_generate_tests(metafunc):
    if "env" in metafunc.fixturenames:
        metafunc.parametrize("env", get_env(metafunc.config.getoption("env")))

Any help is much 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.