Collector
Test result collector for pytest-agent-digest.
| CLASS | DESCRIPTION |
|---|---|
ReportCollector |
Accumulates the |
TestResult |
Represents a single test outcome captured during a pytest session. |
WarningRecord |
Represents a single warning captured during a pytest session. |
| FUNCTION | DESCRIPTION |
|---|---|
strip_ansi |
Remove ANSI escape sequences from text. |
Classes¶
ReportCollector
¶
ReportCollector()
Accumulates the TestResult objects while a pytest session runs.
Wire this into pytest_configure (instantiate) and pytest_runtest_logreport (call add) so the renderer can
consume a fully populated collector at the session end.
Initialize with empty result and warning lists.
| METHOD | DESCRIPTION |
|---|---|
add |
Classify report and append a |
add_warning |
Capture a pytest warning and append a |
| ATTRIBUTE | DESCRIPTION |
|---|---|
counts |
Return a dict of |
has_failures |
Return
TYPE:
|
Attributes¶
counts
property
¶
has_failures
property
¶
has_failures: bool
Return True if any result is "failed" or "xpassed".
| RETURNS | DESCRIPTION |
|---|---|
bool
|
|
Functions¶
add
¶
add(report: TestReport) -> None
Classify report and append a TestResult class if it is a call phase.
report.when == "call" reports are stored for normal outcomes.
report.when == "setup" reports are stored only when skipped, because
@pytest.mark.skip raises a Skipped exception during the setup phase
and never produces a call-phase report.
| PARAMETER | DESCRIPTION |
|---|---|
report
|
The pytest test report to classify and store.
TYPE:
|
add_warning
¶
add_warning(warning_message: WarningMessage, when: str, nodeid: str, location: Optional[tuple[str, int, str]]) -> None
Capture a pytest warning and append a WarningRecord.
| PARAMETER | DESCRIPTION |
|---|---|
warning_message
|
The
TYPE:
|
when
|
The phase when the warning was recorded (
TYPE:
|
nodeid
|
The node ID of the test that triggered the warning, or
TYPE:
|
location
|
A |
TestResult
dataclass
¶
TestResult(node_id: str, outcome: str, longrepr: Optional[str], duration: float, skip_reason: Optional[str])
Represents a single test outcome captured during a pytest session.
| ATTRIBUTE | DESCRIPTION |
|---|---|
node_id |
The pytest node ID (e.g.
TYPE:
|
outcome |
One of
TYPE:
|
longrepr |
Formatted traceback or reason string, stripped of ANSI codes.
|
duration |
Test duration in seconds.
TYPE:
|
skip_reason |
Human-readable skip reason for skipped tests; |
WarningRecord
dataclass
¶
WarningRecord(message: str, category: str, nodeid: str, when: str, location: Optional[tuple[str, int, str]])
Represents a single warning captured during a pytest session.
| ATTRIBUTE | DESCRIPTION |
|---|---|
message |
The warning message text.
TYPE:
|
category |
The warning category class name (e.g.
TYPE:
|
nodeid |
The pytest node ID that triggered the warning, or
TYPE:
|
when |
The phase when the warning was recorded (
TYPE:
|
location |
A |