Skip to content

Harness

provide.testkit.base.harness

Harness Testing Utilities.

Provides utilities for testing CLI harnesses with artifact management.

Classes

HarnessRunner

HarnessRunner(artifact_root: Path)

Test harness runner with artifact management.

Initialize with artifact root directory.

Source code in provide/testkit/base/harness.py
def __init__(self, artifact_root: Path) -> None:
    """Initialize with artifact root directory."""
    self.artifact_root = artifact_root
Functions
run
run(
    command: list[str],
    artifact_path: Path | str,
    stdin: str | bytes | None = None,
    timeout: float = 30.0,
    cwd: Path | None = None,
) -> tuple[int, str, str]

Run command and return text output.

For binary output commands, use run_binary() instead.

Source code in provide/testkit/base/harness.py
def run(
    self,
    command: list[str],
    artifact_path: Path | str,
    stdin: str | bytes | None = None,
    timeout: float = 30.0,
    cwd: Path | None = None,
) -> tuple[int, str, str]:
    """
    Run command and return text output.

    For binary output commands, use run_binary() instead.
    """
    exit_code, stdout_str, stderr_str, _, _ = self._run_internal(
        command, artifact_path, stdin, timeout, cwd
    )
    return exit_code, stdout_str, stderr_str
run_binary
run_binary(
    command: list[str],
    artifact_path: Path | str,
    stdin: str | bytes | None = None,
    timeout: float = 30.0,
    cwd: Path | None = None,
) -> tuple[int, bytes, bytes]

Run command and return binary output.

Use this for commands that output binary data.

Source code in provide/testkit/base/harness.py
def run_binary(
    self,
    command: list[str],
    artifact_path: Path | str,
    stdin: str | bytes | None = None,
    timeout: float = 30.0,
    cwd: Path | None = None,
) -> tuple[int, bytes, bytes]:
    """
    Run command and return binary output.

    Use this for commands that output binary data.
    """
    exit_code, _, _, stdout_bytes, stderr_bytes = self._run_internal(
        command, artifact_path, stdin, timeout, cwd
    )
    return exit_code, stdout_bytes, stderr_bytes

Functions