Skip to content

feat: pytest-theow — native pytest plugin for in-process healing #34

Description

@makiself

Overview

Currently parrot wraps tox/pytest as a subprocess runner and intercepts failures externally. This issue tracks the creation of pytest-theow — a proper pytest plugin that hooks directly into pytest's internals and uses theow for healing in-process.

This replaces the subprocess interception model entirely.

Core flow

test fails
  → pytest_runtest_logreport fires (in-process, has full ExceptionInfo)
  → theow.heal() runs against the failure
  → rule cache checked first → if hit, fix applied immediately
  → if miss, LLM consulted, rule written back
  → on retry=true, test re-runs in same session
  → on session end: summary printed locally / batch PR opened in CI

Key hooks

  • pytest_runtest_logreport — primary failure interception
  • pytest_sessionfinish — summary output and PR creation
  • pytest_runtest_call — access to item (fixture values, parametrize args, test source) for richer context

Local UX

━━━━ theow healing summary ━━━━
✖  test_parse_invoice   → theow: DateParseError — applied fix (rule hit, no LLM)
✖  test_fetch_orders    → theow: ConnectionTimeout — LLM generated fix
✓  test_calculate_tax   → retried + passed after fix

CLI flags

pytest --heal              # heal in-place + retry
pytest --heal --heal-pr    # heal + open batch PR
pytest --heal-dry-run      # show what theow would do, don't apply

CI auto-detection

Detect CI=true env and auto-switch to PR mode — no config needed for the common case.

Config

[tool.pytest-theow]
gh_token = "env:GH_TOKEN"
retry = true
pr_mode = "batch"        # or "per-failure"
rules_dir = ".theow/rules"

Repo

Should live as a separate repo pytest-theow to keep the dependency graph clean. theow stays as the core library, parrot stays as the tox wrapper, pytest-theow is the pytest-native path.

Skeleton

pytest-theow/
├── pyproject.toml        ← pytest11 entry point + theow dep
├── pytest_theow/
│   ├── __init__.py
│   ├── plugin.py         ← hooks (~80 lines)
│   ├── healer.py         ← ExceptionInfo → theow.heal() adapter
│   └── reporter.py       ← local summary + batch PR logic

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions