resetall(side_effect=True) removes the warning about using mocks as context managers
I maintainer di solito rispondono entro 1 giorno
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
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
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pytest-dev/pytest-mock
-
Mocks created by mocker.patch.multiple are not handled like other patchesForse già presa @patrickswedish l’ha presa 6 giorni fa. Apertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 78/100
pytest-dev/pytest-mock#638 ·
I maintainer di solito rispondono entro 1 giorno
-
spy.reset_mock(side_effect=True) makes spies stop calling the spied codeForse già presa @saifmodan2006 l’ha presa 6 giorni fa. Apertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
pytest-dev/pytest-mock#636 ·
I maintainer di solito rispondono entro 1 giorno
-
Spy with async function not registering calls until coroutine is awaitedForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
pytest-dev/pytest-mock#519 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
mocker.stub() is a coroutine functionForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertaquestion
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
pytest-dev/pytest-mock#375 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
question
Difficoltà 3/5 1-2 giorni Idoneità per principianti 38/100
pytest-dev/pytest-mock#374 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di pytest-dev/pytest-mock
Issue simili
-
[Resource]: LoreApertaresource-submission validation-passed
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
hesreallyhim/awesome-claude-code#3234 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
openminion/openminion#376 ·
I maintainer di solito rispondono entro 1 giorno
-
Type: ☹︎ Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
posit-dev/great-tables#1028 ·
I maintainer di solito rispondono entro 1 giorno
-
integration: apple_tv
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
home-assistant/core#188282 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
A "since" range is worded as a career: "the past two seasons" says "regular season career (2025 on)"ApertaP4: low
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
jeffknupp/association#538 ·