Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/_pytest/assertion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def pytest_runtest_protocol(item: Item) -> Generator[None, None, None]:
comparison for the test.
"""

ihook = item.ihook

def callbinrepr(op, left: object, right: object) -> Optional[str]:
"""Call the pytest_assertrepr_compare hook and prepare the result

Expand All @@ -139,7 +141,7 @@ def callbinrepr(op, left: object, right: object) -> Optional[str]:
The result can be formatted by util.format_explanation() for
pretty printing.
"""
hook_result = item.ihook.pytest_assertrepr_compare(
hook_result = ihook.pytest_assertrepr_compare(
config=item.config, op=op, left=left, right=right
)
for new_expl in hook_result:
Expand All @@ -155,12 +157,10 @@ def callbinrepr(op, left: object, right: object) -> Optional[str]:
saved_assert_hooks = util._reprcompare, util._assertion_pass
util._reprcompare = callbinrepr

if item.ihook.pytest_assertion_pass.get_hookimpls():
if ihook.pytest_assertion_pass.get_hookimpls():

def call_assertion_pass_hook(lineno: int, orig: str, expl: str) -> None:
item.ihook.pytest_assertion_pass(
item=item, lineno=lineno, orig=orig, expl=expl
)
ihook.pytest_assertion_pass(item=item, lineno=lineno, orig=orig, expl=expl)

util._assertion_pass = call_assertion_pass_hook

Expand Down
5 changes: 3 additions & 2 deletions src/_pytest/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ def pytest_sessionfinish(session: "Session") -> None:


def pytest_runtest_protocol(item: Item, nextitem: Optional[Item]) -> bool:
item.ihook.pytest_runtest_logstart(nodeid=item.nodeid, location=item.location)
ihook = item.ihook
ihook.pytest_runtest_logstart(nodeid=item.nodeid, location=item.location)
runtestprotocol(item, nextitem=nextitem)
item.ihook.pytest_runtest_logfinish(nodeid=item.nodeid, location=item.location)
ihook.pytest_runtest_logfinish(nodeid=item.nodeid, location=item.location)
return True


Expand Down