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

can not retrieve caplog results in pytest-bdd specifications

Đang mở
#597 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ó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Khá 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 bằng cách chạy ví dụ inline của pytest-bdd với fixture caplog và kiểm tra xem logging.info("log this") có xuất hiện trong logs.records hay không. Theo dõi cách step @when với target_fixture="logs" truyền caplog vào step @then. Hoàn tất khi assertion thành công và các record đã thu thập vẫn khả dụng cho định nghĩa step.

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

Mô tả

pytest caplog fixture enables the capture of logs so they can be used in assertions.

It seems that py.test bdd steps are capturing out streams somehow so this information is lost. An example of test that fails:


"""we can verify logs feature tests."""

import logging
from pytest_bdd import (
    scenario,
    then,
    when,
)

@scenario('log.feature', 'Logs are retrieved')
def test_logs_are_retrieved():
    """Logs are retrieved."""


@when('user performs an auditable action', target_fixture="logs")
def _(caplog):
    """user performs an auditable action."""
    logging.info("log this")
    return caplog


@then('action is audited')
def _(logs):
    """action is audited."""
    assert logs.records
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

  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.