Skip to content

Commit

Permalink
modernize: new-style hook wrapper for pytest_runtest_makereport
Browse files Browse the repository at this point in the history
  • Loading branch information
aurzenligl committed Feb 19, 2024
1 parent fce6152 commit 35f20ca
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pytest_logger/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,13 @@ def pytest_runtest_teardown(self, item, nextitem):
if logger:
logger.on_teardown()

@pytest.hookimpl(hookwrapper=True)
@pytest.hookimpl(wrapper=True)
def pytest_runtest_makereport(self, item, call):
outcome = yield
tr = outcome.get_result()
report = yield
logger = getattr(item, '_logger', None)
if logger:
if self._logsdir and self._split_by_outcome_subdir and tr.outcome in self._split_by_outcome_outcomes:
split_by_outcome_logdir = self._logsdir / self._split_by_outcome_subdir / tr.outcome
if self._logsdir and self._split_by_outcome_subdir and report.outcome in self._split_by_outcome_outcomes:
split_by_outcome_logdir = self._logsdir / self._split_by_outcome_subdir / report.outcome
nodeid = _sanitize_nodeid(item.nodeid)
nodepath = os.path.dirname(nodeid)
outcomedir = split_by_outcome_logdir / nodepath
Expand All @@ -116,6 +115,7 @@ def pytest_runtest_makereport(self, item, call):
_refresh_link(destdir_relpath, split_by_outcome_logdir / nodeid)
if call.when == 'teardown':
logger.on_makereport()
return report


class LoggerState:
Expand Down

0 comments on commit 35f20ca

Please sign in to comment.