Metadata-Version: 2.4
Name: testgap
Version: 0.1.0a0
Summary: AI-powered test generator that closes coverage gaps in your PRs — only suggests tests that actually pass.
Project-URL: Homepage, https://github.com/nrhys2005/test-gap
Project-URL: Issues, https://github.com/nrhys2005/test-gap/issues
Author: Sanghun Lee
License: MIT License
        
        Copyright (c) 2026 SANGHUN LEE
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.10
Requires-Dist: coverage>=7.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: pytest-cov>=4.0
Requires-Dist: pytest-json-report>=1.5
Requires-Dist: pyyaml>=6.0
Requires-Dist: rich>=13.0.0
Requires-Dist: tomli>=2.0; python_version < '3.11'
Requires-Dist: typer>=0.12.0
Provides-Extra: dev
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
Requires-Dist: pytest-json-report>=1.5; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.5.0; extra == 'dev'
Provides-Extra: llm
Requires-Dist: litellm>=1.40.0; extra == 'llm'
Description-Content-Type: text/markdown

# TestGap

AI-powered test generator that closes coverage gaps in your PRs — only suggests tests that actually pass.

> **Status:** alpha. `testgap init` and `testgap diff` work today (non-interactive). `testgap diff --review` is in progress.

TestGap analyzes the uncovered code in your diff, generates pytest tests using your chosen LLM (Claude, GPT, Gemini, or local Ollama), and only suggests tests that have been executed and passed. Provider-agnostic, diff-focused, and verified — no hallucinated tests.

## Install

```bash
pip install -e ".[llm]"   # llm extra pulls in litellm for live calls
```

(Once published: `pip install testgap[llm]`.)

## Quick start

```bash
cd your-project
testgap init                  # detects pytest / src layout / test dir, writes .testgap.yml
testgap diff                  # generate tests for uncovered diff lines, validate them
testgap diff --base origin/main --max-functions 3
```

`testgap diff` runs end-to-end:

1. Resolves the base ref (`origin/HEAD` → `main` → `master`, override with `--base`).
2. Computes the changed-line set from `git diff base..HEAD`.
3. Runs `pytest --cov` to find which changed lines are not executed.
4. Groups uncovered lines into enclosing functions/methods via AST.
5. For each function, calls the configured LLM with a few-shot prompt that
   imitates existing tests in the project.
6. Writes the generated test to a temp file under `tests/`, runs pytest against it,
   and only reports tests that actually passed.

Suggestions are not committed automatically — that's the `--review` interactive mode (coming next).

## Configuration

`testgap init` creates a `.testgap.yml` like:

```yaml
version: 1
project:
  language: python
  test_framework: pytest
  source_paths: ["src/"]
  test_paths: ["tests/"]
coverage:
  threshold: 80
  diff_threshold: 90
  exclude:
    - "**/migrations/**"
    - "**/__init__.py"
llm:
  model: anthropic/claude-sonnet-4-6
  max_cost_per_run: 2.0
  max_retries: 2
generation:
  style: match_existing
  include_docstrings: true
  max_tests_per_function: 3
```

### LLM provider

TestGap uses [LiteLLM](https://docs.litellm.ai/) for provider abstraction. Set the matching env var for the model you choose:

| Model | Env var |
| --- | --- |
| `anthropic/claude-sonnet-4-6` | `ANTHROPIC_API_KEY` |
| `openai/gpt-4o` | `OPENAI_API_KEY` |
| `gemini/gemini-2.0-flash` | `GEMINI_API_KEY` |
| `ollama/qwen2.5-coder` | — (local) |

## Development

```bash
pip install -e ".[dev]"
pytest
```

## License

MIT
