only_rerun with exception raised from fixture teardown reruns test but report previous runs as failure
@hfycium đang làm issue này rồi.
Từ ngày 6/10/2026.
Đá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
- 48/100
Hướng nghiên cứu
Bắt đầu từ đường dẫn xử lý báo cáo cho setup, call và teardown, sau đó theo dõi cách bộ lọc ngoại lệ rerun_only quyết định liệu một test có được chạy lại hay không. Tái hiện ví dụ MyCustomError trong fixture-teardown và xác minh rằng các lần chạy lại do teardown kích hoạt được đưa vào kết quả cuối cùng, thay vì được báo cáo là các lỗi từ những lần chạy trước.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi.
I have a need to do some checks in a fixture teardown to determine whether a test should rerun or not.
Because rerunfailures only allows filtering based on exception, what I had in mind is that to check whatever I want in the fixture and raise the custom exception so the test will rerun.
However, while this package detects a rerun is needed when processing the teardown report, the call (test) report was already processed and it was not marked to be rerun, because the rerun_only condition didn't match the test exception, as the custom exception was raised from the fixture.
Eventually, the test does re-run until it pass, but pytest still report the test failure outcomes.
Note that the reruns works just fine when not using only_rerun condition.
Example code:
import random
import pytest
class MyCustomError(Exception):
pass
@pytest.fixture
def rerun_custom_checker(request):
yield
if request.node.rep_call.outcome == "passed":
return
raise MyCustomError()
@pytest.mark.flaky(reruns=10, reruns_delay=1, only_rerun=["MyCustomError"])
def test_example(rerun_custom_checker):
i = random.randint(2, 4)
if i != 3:
assert False
What I had in mind, is to pre-process the reports and set a flag whether rerun is needed, if it was found to be needed for setup/call/teardown.
Then, when processing the reports as usual, and just check for this flag.
Something like:
I can raise a PR with that change, assuming this solution is acceptable (It works fine when testing this change)
- Ngôn ngữ chính
- Python
- Star
- 480
- Fork
- 110
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
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-rerunfailures
-
Zero rerun delay can abort with OverflowError for a large finite backoff factorCó thể đã có người làm @AryanRG đã nhận 8 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Non-finite rerun delay settings abort pytest with INTERNALERRORCó thể đã có người làm @Arham-Begani đã nhận 6 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
-
fail-on-flaky returns success after a rerun with xdistCó thể đã có người làm @harbinresearcher đã nhận 9 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 15/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
pytest-dev/pytest-rerunfailures#326 · 7 bình luận ·
-
Add ability to raise runtime warnings on rerunsCó thể đã có người làm @LouisDeconinck đã nhận 37 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
pytest-dev/pytest-rerunfailures#318 · 2 bình luận ·
Tất cả issue của pytest-dev/pytest-rerunfailures
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
conda-forge/conda-forge-bot#7025 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
chore(ci): publish.yml's release-job comment counts the hand-created Releases as all of themĐang mởarea:ci
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
catincloud-labs/dagster-dex#149 ·
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 84/100
home-assistant/core#188424 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Review backlog (docs-currency): README 'CI run' link lands on a run whose overall badge is cancelledĐang mởagent/reviewer needs-kind needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
projectbluefin/utah#880 · 2 bình luận ·
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 76/100
redis/memtier_benchmark#850 ·
Maintainer thường phản hồi trong vòng 1 ngày