Skip to content

Commit cf19df9

Browse files
pytest_runtest_makereport is updated (refactoring+documentation)
1 parent 712de46 commit cf19df9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/conftest.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,12 @@ def helper__makereport__call(
390390

391391
@pytest.hookimpl(hookwrapper=True)
392392
def pytest_runtest_makereport(item: pytest.Function, call: pytest.CallInfo):
393+
#
394+
# https://docs.pytest.org/en/7.1.x/how-to/writing_hook_functions.html#hookwrapper-executing-around-other-hooks
395+
#
396+
# Note that hook wrappers don’t return results themselves,
397+
# they merely perform tracing or other side effects around the actual hook implementations.
398+
#
393399
assert item is not None
394400
assert call is not None
395401
# it may be pytest.Function or _pytest.unittest.TestCaseFunction
@@ -400,6 +406,8 @@ def pytest_runtest_makereport(item: pytest.Function, call: pytest.CallInfo):
400406
assert outcome is not None
401407
assert type(outcome) == pluggy.Result # noqa: E721
402408

409+
assert type(call.when) == str
410+
403411
if call.when == "collect":
404412
return
405413

@@ -414,7 +422,9 @@ def pytest_runtest_makereport(item: pytest.Function, call: pytest.CallInfo):
414422
if call.when == "teardown":
415423
return
416424

417-
assert False
425+
errMsg = "[pytest_runtest_makereport] unknown 'call.when' value: [{0}].".format(call.when)
426+
427+
raise RuntimeError(errMsg)
418428

419429

420430
# /////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy