@@ -390,6 +390,12 @@ def helper__makereport__call(
390390
391391@pytest .hookimpl (hookwrapper = True )
392392def 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+ #
393399assert item is not None
394400assert 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):
400406assert outcome is not None
401407assert type (outcome )== pluggy .Result # noqa: E721
402408
409+ assert type (call .when )== str
410+
403411if call .when == "collect" :
404412return
405413
@@ -414,7 +422,9 @@ def pytest_runtest_makereport(item: pytest.Function, call: pytest.CallInfo):
414422if call .when == "teardown" :
415423return
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# /////////////////////////////////////////////////////////////////////////////