Skip to content

Index

Top-level package for pytest_agent_digest.

The pytest11 entry point points to this package, so pytest hook functions are imported here from plugin to make them discoverable.

MODULE DESCRIPTION
collector

Test result collector for pytest-agent-digest.

plugin

pytest plugin hooks for pytest-agent-digest.

renderer

Markdown renderer for pytest-agent-digest.

CLASS DESCRIPTION
AgentDigestPlugin

Internal plugin class that holds the per-session state.

FUNCTION DESCRIPTION
get_output_modes

Return the set of output modes requested via --agent-digest.

get_report_path

Return the output path for the Markdown digest file.

pytest_addoption

Register pytest-agent-digest command-line options.

pytest_configure

Configure the pytest-agent-digest plugin.

Classes

AgentDigestPlugin

AgentDigestPlugin()

Internal plugin class that holds the per-session state.

Registered by pytest_configure so that pytest_runtest_logreport and pytest_sessionfinish share the same ~pytest_agent_digest.collector.ReportCollector without a global.

Initialize the plugin with a fresh collector.

METHOD DESCRIPTION
pytest_runtest_logreport

Forward each test report to the collector.

pytest_sessionfinish

Finalize the digest at the end of the test session.

Functions

pytest_runtest_logreport
pytest_runtest_logreport(report: TestReport) -> None

Forward each test report to the collector.

PARAMETER DESCRIPTION
report

The test report for the current phase.

TYPE: TestReport

pytest_sessionfinish
pytest_sessionfinish(session: Session, exitstatus: int) -> None

Finalize the digest at the end of the test session.

When term mode is active, renders the Markdown digest and prints it to stdout. When file mode is active, writes the Markdown digest to disk and prints a confirmation line. Both modes may be active simultaneously.

PARAMETER DESCRIPTION
session

The pytest session object.

TYPE: Session

exitstatus

The exit status code for the session.

TYPE: int

Functions

get_output_modes

get_output_modes(config: Config) -> set[str]

Return the set of output modes requested via --agent-digest.

PARAMETER DESCRIPTION
config

The pytest configuration object.

TYPE: Config

RETURNS DESCRIPTION
set[str]

A set of mode strings ("term", "file"), or an empty set if the flag was not passed.

get_report_path

get_report_path(config: Config) -> Path

Return the output path for the Markdown digest file.

Resolution order:

  1. --agent-digest-file CLI flag
  2. agent_digest_file ini option
  3. Hard-coded default test-results.md
PARAMETER DESCRIPTION
config

The pytest configuration object.

TYPE: Config

RETURNS DESCRIPTION
Path

A pathlib.Path pointing to the desired report file location.

pytest_addoption

pytest_addoption(parser: Parser) -> None

Register pytest-agent-digest command-line options.

PARAMETER DESCRIPTION
parser

The pytest argument parser.

TYPE: Parser

pytest_configure

pytest_configure(config: Config) -> None

Configure the pytest-agent-digest plugin.

Instantiates the AgentDigestPlugin class and registers it so its hooks are active for the session. When term mode is active, unregisters pytest's built-in terminal reporter so only the Markdown digest appears on stdout.

Marked trylast=True so that the built-in terminal reporter is already registered by the time this hook runs, making it safe to unregister.

PARAMETER DESCRIPTION
config

The pytest configuration object.

TYPE: Config