Flaky reruns autouse session-scoped fixtures when a tests fails one of its runs

オープン
#207 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
testing-qa

調査の方向性

提供された pytest fixture と flaky test で問題を再現し、その後、plugin の rerun 処理と fixture のセットアップ動作を調査してください。session スコープの autouse fixture が rerun 全体を通して 1 回だけ実行される一方で、flaky test が以前の trace ファイルを削除せずに設定された実行回数を完了することを確認してください。

索引モデルが issue の本文から書いたものです。

説明

When a test fails and is rerun, Flaky reruns session-scoped autouse fixtures. For example, running this test:

import pytest

@pytest.fixture(scope="session", autouse=True)
def my_session_scoped_autouse_fixture():
    print("\nIn session scope autouse fixture")

@pytest.mark.flaky(max_runs=3)
def test_flaky_reruns(local_list = []):
    local_list.append(0)
    assert len(local_list)==3

calls the fixture 3 times:

============================= test session starts ==============================
collecting ... collected 1 item

test_it.py::test_flaky_reruns 
In session scope autouse fixture

In session scope autouse fixture

In session scope autouse fixture
PASSED

============================== 1 passed in 0.01s ===============================

Process finished with exit code 0

This can cause unexpected behaviors. In my case, I'm using the pytest-playwright package which has a session-scoped autouse fixture that deletes the output directory where traces are stored for failing tests. If a test fails and is rerun, any previously created trace files are deleted.

主要言語
Python
スター
399
フォーク
58
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

box/flaky のほかの issue

box/flaky の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。