Skip to content

Commit 421a363

Browse files
authored
Merge pull request #277 from nicoddemus/improve-standalone-mock-test
2 parents 746ae68 + 0440115 commit 421a363

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

tests/test_pytest_mock.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -708,10 +708,14 @@ def test_foo(mocker):
708708

709709
def test_standalone_mock(testdir: Any) -> None:
710710
"""Check that the "mock_use_standalone" is being used."""
711+
pytest.importorskip("mock")
712+
711713
testdir.makepyfile(
712714
"""
715+
import mock
716+
713717
def test_foo(mocker):
714-
pass
718+
assert mock.MagicMock is mocker.MagicMock
715719
"""
716720
)
717721
testdir.makeini(
@@ -721,8 +725,7 @@ def test_foo(mocker):
721725
"""
722726
)
723727
result = testdir.runpytest_subprocess()
724-
assert result.ret == 3
725-
result.stderr.fnmatch_lines(["*No module named 'mock'*"])
728+
assert result.ret == 0
726729

727730

728731
@pytest.mark.usefixtures("needs_assert_rewrite")

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ envlist = py{37,38,39,310}, norewrite
66
passenv = USER USERNAME
77
deps =
88
coverage
9+
mock
910
pytest-asyncio
1011
commands =
1112
coverage run --append --source={envsitepackagesdir}/pytest_mock -m pytest tests

0 commit comments

Comments
 (0)