only_rerun with exception raised from fixture teardown reruns test but report previous runs as failure
評価
調査の方向性
setup、call、teardown のレポート処理パスから始め、例外フィルター rerun_only がテストを再実行するかどうかをどのように判断するかを追跡します。fixture-teardown の MyCustomError の例を再現し、teardown によってトリガーされた再実行が、以前の実行による失敗として報告されるのではなく、最終結果に含まれることを確認します。
索引モデルが issue の本文から書いたものです。
説明
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)
- 主要言語
- Python
- スター
- 480
- フォーク
- 110
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pytest-dev/pytest-rerunfailures のほかの issue
-
Zero rerun delay can abort with OverflowError for a large finite backoff factor対応中かも @AryanRG が 9 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
Non-finite rerun delay settings abort pytest with INTERNALERROR対応中かも @Arham-Begani が 7 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
-
fail-on-flaky returns success after a rerun with xdist対応中かも @harbinresearcher が 10 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 15/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
pytest-dev/pytest-rerunfailures#326 · コメント 7 件 ·
-
Add ability to raise runtime warnings on reruns対応中かも @LouisDeconinck が 38 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
pytest-dev/pytest-rerunfailures#318 · コメント 2 件 ·
pytest-dev/pytest-rerunfailures の issue をすべて見る
似ている issue
-
request-theme
難易度 1/5 1時間未満 初心者へのやさしさ 66/100
LizardByte/ThemerrDB#9575 ·
メンテナーはふだん 1 日以内に返信
-
author-page correction
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
acl-org/acl-anthology#10599 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
zilliztech/memsearch#818 ·
メンテナーはふだん 1 日以内に返信
-
[FAQ] Commit ID for Projects対応中かも @github-actions が今日担当しました。 オープンfaq-proposal
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
DataTalksClub/faq#503 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
README.zh-CN/ja/es still hard-code 501 test counts after README.md went count-free対応中かも @Aaqibhafeezkhan が今日担当しました。 オープンbeginner documentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
BistaDinesh03/critique#164 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信