Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#637 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Parsiffall1 ci sta già lavorando.

Dal 17/10/2026.

  • #646 di @Parsiffall1 — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
testing-qa

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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).

Lingua principale
Python
Stelle
2k
Fork
186
Merge medio
1g 22h
PR unite (30g)
25

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pytest-dev/pytest-mock

Tutte le issue di pytest-dev/pytest-mock

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.