resetall(side_effect=True) removes the warning about using mocks as context managers
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 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 の本文から書いたものです。
説明
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
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pytest-dev/pytest-mock のほかの issue
-
Mocks created by mocker.patch.multiple are not handled like other patches対応中かも @patrickswedish が 6 日前に担当しました。 オープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 78/100
pytest-dev/pytest-mock#638 ·
メンテナーはふだん 1 日以内に返信
-
spy.reset_mock(side_effect=True) makes spies stop calling the spied code対応中かも @saifmodan2006 が 6 日前に担当しました。 オープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
pytest-dev/pytest-mock#636 ·
メンテナーはふだん 1 日以内に返信
-
Spy with async function not registering calls until coroutine is awaited再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
pytest-dev/pytest-mock#519 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
mocker.stub() is a coroutine function再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンquestion
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
pytest-dev/pytest-mock#375 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
question
難易度 3/5 1〜2日 初心者へのやさしさ 38/100
pytest-dev/pytest-mock#374 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
pytest-dev/pytest-mock の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
iceboundrock/AutoForge#304 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
fossasia/visdom-dev#77 ·
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
aws-cloudformation/cfn-lint#4890 ·
メンテナーはふだん 2 日以内に返信