Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

resetall(side_effect=True) removes the warning about using mocks as context managers

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

メンテナーはふだん 1 日以内に返信

@Parsiffall1 がすでに取り組んでいます。

2026年10月17日 から。

  • #646 @Parsiffall1 による — オープン

評価

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

調査の方向性

Start with the mocker.resetall(side_effect=True) implementation and the context-manager hook installed by mocker.patch; linked pull request #646 already targets this work. Run the provided reproduction alongside existing resetall and spy side-effect tests. Done means a patched mock still emits PytestMockWarning after reset without regressing spy side effects.

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

説明

bug

mocker.patch and friends install a side_effect on the mock's __enter__ that emits PytestMockWarning when the mock is used as a context manager. mocker.resetall(side_effect=True) resets the side effects of child mocks too, so the warning is gone afterwards:

import pytest
from pytest_mock import PytestMockWarning

def test_warning_after_resetall(mocker):
    m = mocker.patch("os.getcwd")
    mocker.resetall(side_effect=True)
    with pytest.warns(PytestMockWarning):  # fails: DID NOT WARN
        with m:
            pass

Reproduced on 3.16.1, with any MagicMock patch, spies included. resetall() could reinstall the hook after the reset, like it now restores the side_effect of spies (#633).

主要言語
Python
スター
2k
フォーク
186
平均マージ
1日 22時間
マージ済み PR(30日)
25

環境構築

はじめの一歩

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

pytest-dev/pytest-mock のほかの issue

pytest-dev/pytest-mock の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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