Skip to content

Commit e8583f0

Browse files
committed
Replaced __multicall__ examples in docs by hookwrapper
Fix pytest-dev#929
1 parent 729b5e9 commit e8583f0

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

doc/en/example/simple.rst

+10-9
Original file line numberDiff line numberDiff line change
@@ -534,23 +534,24 @@ case we just write some informations out to a ``failures`` file::
534534
import pytest
535535
import os.path
536536

537-
@pytest.hookimpl(tryfirst=True)
538-
def pytest_runtest_makereport(item, call, __multicall__):
537+
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
538+
def pytest_runtest_makereport(item, call):
539539
# execute all other hooks to obtain the report object
540-
rep = __multicall__.execute()
540+
outcome = yield
541+
rep = outcome.get_result()
541542

542543
# we only look at actual failing test calls, not setup/teardown
543544
if rep.when == "call" and rep.failed:
544545
mode = "a" if os.path.exists("failures") else "w"
545546
with open("failures", mode) as f:
546547
# let's also access a fixture for the fun of it
547-
if "tmpdir" in item.funcargs:
548+
if "tmpdir" in item.fixturenames:
548549
extra = " (%s)" % item.funcargs["tmpdir"]
549550
else:
550551
extra = ""
551552

552553
f.write(rep.nodeid + extra + "\n")
553-
return rep
554+
554555

555556
if you then have failing tests::
556557

@@ -606,16 +607,16 @@ here is a little example implemented via a local plugin::
606607

607608
import pytest
608609

609-
@pytest.hookimpl(tryfirst=True)
610-
def pytest_runtest_makereport(item, call, __multicall__):
610+
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
611+
def pytest_runtest_makereport(item, call):
611612
# execute all other hooks to obtain the report object
612-
rep = __multicall__.execute()
613+
outcome = yield
614+
rep = outcome.get_result()
613615

614616
# set an report attribute for each phase of a call, which can
615617
# be "setup", "call", "teardown"
616618

617619
setattr(item, "rep_" + rep.when, rep)
618-
return rep
619620

620621

621622
@pytest.fixture

0 commit comments

Comments
 (0)