File: conftest.py

package info (click to toggle)
ceccomp 4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,632 kB
  • sloc: ansic: 6,474; python: 1,039; makefile: 248; sh: 145
file content (17 lines) | stat: -rw-r--r-- 508 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from types import SimpleNamespace
import pytest

@pytest.fixture
def errns() -> SimpleNamespace:
    return SimpleNamespace()

# hook pytest report to print stderr
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_makereport(item, call):
    outcome = yield
    report = outcome.get_result()

    if report.when == 'call' and report.failed:
        ns = item.funcargs.get('errns')
        if hasattr(ns, 'stderr'):
            report.sections.append(('Process Standard Error', ns.stderr))