Skip to content

Commit

Permalink
Merge pull request #277 from nicoddemus/improve-standalone-mock-test
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus authored Apr 6, 2022
2 parents 746ae68 + 0440115 commit 421a363
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/test_pytest_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,10 +708,14 @@ def test_foo(mocker):

def test_standalone_mock(testdir: Any) -> None:
"""Check that the "mock_use_standalone" is being used."""
pytest.importorskip("mock")

testdir.makepyfile(
"""
import mock
def test_foo(mocker):
pass
assert mock.MagicMock is mocker.MagicMock
"""
)
testdir.makeini(
Expand All @@ -721,8 +725,7 @@ def test_foo(mocker):
"""
)
result = testdir.runpytest_subprocess()
assert result.ret == 3
result.stderr.fnmatch_lines(["*No module named 'mock'*"])
assert result.ret == 0


@pytest.mark.usefixtures("needs_assert_rewrite")
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ envlist = py{37,38,39,310}, norewrite
passenv = USER USERNAME
deps =
coverage
mock
pytest-asyncio
commands =
coverage run --append --source={envsitepackagesdir}/pytest_mock -m pytest tests
Expand Down

0 comments on commit 421a363

Please sign in to comment.