Skip to content

Commit 931ce18

Browse files
simplify and fix the mock fixture
directly use the mocker fixture instead of secretly invoking it outside of pytest resulting in 2 objects in case of mixed usage
1 parent 4e55167 commit 931ce18

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pytest_mock.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,12 @@ def mocker():
7878
result.stopall()
7979

8080

81-
@pytest.yield_fixture
82-
def mock():
81+
@pytest.fixture
82+
def mock(mocker):
8383
"""
8484
Same as "mocker", but kept only for backward compatibility.
8585
"""
8686
import warnings
8787
warnings.warn('"mock" fixture has been deprecated, use "mocker" instead',
8888
DeprecationWarning)
89-
for m in mocker():
90-
yield m
89+
return mocker

0 commit comments

Comments
 (0)