AI-powered test generator that closes coverage gaps in your PRs — only suggests tests that actually pass.
Reason this release was yanked:
Superseded by 0.1.0a2 (adds TG-401 Ollama auto-detect, TG-406 session logs, TG-412 auto pytest-import fix, TG-413 LiteLLM noise capture, TG-414 Ollama.app hint matrix — none of which were in this build)
Project description
TestGap
AI-powered test generator that closes coverage gaps in your PRs — only suggests tests that actually pass.
Status: alpha.
testgap initandtestgap diffwork today (non-interactive).testgap diff --reviewis 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
pip install -e ".[llm]" # llm extra pulls in litellm for live calls
(Once published: pip install testgap[llm].)
Quick start
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:
- Resolves the base ref (
origin/HEAD→main→master, override with--base). - Computes the changed-line set from
git diff base..HEAD. - Runs
pytest --covto find which changed lines are not executed. - Groups uncovered lines into enclosing functions/methods via AST.
- For each function, calls the configured LLM with a few-shot prompt that imitates existing tests in the project.
- 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:
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 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
pip install -e ".[dev]"
pytest
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file testgap-0.1.0a0.tar.gz.
File metadata
- Download URL: testgap-0.1.0a0.tar.gz
- Upload date:
- Size: 43.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dc8e916af30bccccfb85eee6b6cbb2eaf1c0ee1ccd73ea7f3a303a48217643b
|
|
| MD5 |
81efd13ac02e885042a91239b08720d7
|
|
| BLAKE2b-256 |
29b522850bfc24f712fd95d05e2573b2c89fbbaf2939ed6db360498b601bdff2
|
File details
Details for the file testgap-0.1.0a0-py3-none-any.whl.
File metadata
- Download URL: testgap-0.1.0a0-py3-none-any.whl
- Upload date:
- Size: 35.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e16e75860b30e8b08128e58cf2419a4646662f3693a9da5a799dc1b4ca9d0e4
|
|
| MD5 |
af903f3638ae8f894ae931bbe0a0386f
|
|
| BLAKE2b-256 |
9b9da083f2583750d3ddcc492949cca1b33177af305d38eb50fc20e965897fcb
|