| 1 |
from types import SimpleNamespace |
| 2 |
import pytest |
| 3 |
|
| 4 |
@pytest.fixture |
| 5 |
def errns() -> SimpleNamespace: |
| 6 |
return SimpleNamespace() |
| 7 |
|
| 8 |
# hook pytest report to print stderr |
| 9 |
@pytest.hookimpl(tryfirst=True, hookwrapper=True) |
| 10 |
def pytest_runtest_makereport(item, call): |
| 11 |
outcome = yield |
| 12 |
report = outcome.get_result() |
| 13 |
|
| 14 |
if report.when == 'call' and report.failed: |
| 15 |
ns = item.funcargs.get('errns') |
| 16 |
if hasattr(ns, 'stderr'): |
| 17 |
report.sections.append(('Process Standard Error', ns.stderr)) |