Skip to content

Commit 92418e3

Browse files
authored
Merge pull request #143 from ikonst/no_terminal
Support terminal plugin being disabled
2 parents d9d785e + 7248438 commit 92418e3

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
1.10.4
2+
------
3+
4+
* Fix plugin when 'terminal' plugin is disabled
5+
16
1.10.3
27
------
38

pytest_mock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def parse_ini_boolean(value):
328328

329329

330330
def pytest_configure(config):
331-
tb = config.getoption("--tb")
331+
tb = config.getoption("--tb", default="auto")
332332
if (
333333
parse_ini_boolean(config.getini("mock_traceback_monkeypatch"))
334334
and tb != "native"

test_pytest_mock.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,22 @@ def test_foo(mocker):
561561
) # make sure there are no duplicated tracebacks (#44)
562562

563563

564+
def test_monkeypatch_no_terminal(testdir):
565+
"""Don't crash without 'terminal' plugin.
566+
"""
567+
testdir.makepyfile(
568+
"""
569+
def test_foo(mocker):
570+
stub = mocker.stub()
571+
stub(1, greet='hello')
572+
stub.assert_called_once_with(1, greet='hey')
573+
"""
574+
)
575+
result = runpytest_subprocess(testdir, "-p", "no:terminal", "-s")
576+
assert result.ret == 1
577+
assert result.stdout.lines == []
578+
579+
564580
@pytest.mark.skipif(sys.version_info[0] < 3, reason="Py3 only")
565581
def test_standalone_mock(testdir):
566582
"""Check that the "mock_use_standalone" is being used.

0 commit comments

Comments
 (0)