diff-to-test 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,140 @@
1
+ Metadata-Version: 2.5
2
+ Name: diff-to-test
3
+ Version: 0.0.1
4
+ Summary: Diff-driven, style-cloning, self-healing unit test generator (CLI & Composite GitHub Action)
5
+ Project-URL: Homepage, https://github.com/mehmetakifkucukkaya/diff2test
6
+ Project-URL: Repository, https://github.com/mehmetakifkucukkaya/diff2test
7
+ Project-URL: Issues, https://github.com/mehmetakifkucukkaya/diff2test/issues
8
+ Author: Mehmet Akif
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: ai,git-diff,github-action,llm,pytest,testing,unit-tests
12
+ Classifier: Development Status :: 2 - Pre-Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Testing
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: httpx>=0.27
23
+ Requires-Dist: pyyaml>=6.0
24
+ Requires-Dist: typer>=0.12
25
+ Provides-Extra: dev
26
+ Requires-Dist: pre-commit>=3.7; extra == 'dev'
27
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
28
+ Requires-Dist: pytest>=8.0; extra == 'dev'
29
+ Requires-Dist: ruff>=0.6; extra == 'dev'
30
+ Provides-Extra: litellm
31
+ Requires-Dist: litellm>=1.40; extra == 'litellm'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # diff2test
35
+
36
+ English | [Türkçe](README.tr.md)
37
+
38
+ [![CI](https://github.com/mehmetakifkucukkaya/diff2test/actions/workflows/ci.yml/badge.svg)](https://github.com/mehmetakifkucukkaya/diff2test/actions/workflows/ci.yml)
39
+ [![PyPI version](https://img.shields.io/pypi/v/diff-to-test.svg)](https://pypi.org/project/diff-to-test/)
40
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
41
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
42
+
43
+ **diff2test** is an open-source Python CLI and Composite GitHub Action that analyzes your `git diff`, learns your repository's existing test style via few-shot cloning, generates unit or widget tests for changed code, and verifies them with a self-healing retry loop before keeping or reporting anything.
44
+
45
+ ![diff2test CLI demo](docs/assets/cli-demo.gif)
46
+
47
+ > See it in action on a live pull request in [mehmetakifkucukkaya/diff2test-demo](https://github.com/mehmetakifkucukkaya/diff2test-demo) ([Demo PR #1](https://github.com/mehmetakifkucukkaya/diff2test-demo/pull/1)).
48
+
49
+ ## How It Works
50
+
51
+ 1. **Diff & Filter:** Extracts changed source files from `git diff` (ignoring lockfiles, generated code, docs, and existing tests) and identifies modified symbols.
52
+ 2. **Few-Shot Style Cloning:** Finds the closest existing tests in your repository so generated tests match your imports, fixtures, mocks, and naming conventions.
53
+ 3. **Self-Healing Verification:** Writes the generated test transactionally, runs your project's test command, and feeds failures back into the LLM (up to `max_retries`) while guarding against hollow tests (`assert True`, skipped tests, or dropped assertions).
54
+ 4. **Safe Delivery:** Keeps only passing tests locally, or posts/updates a single PR report comment (`comment` mode) or commits with `[skip ci]` + `Generated-By: diff2test` (`commit` mode).
55
+
56
+ ## Why diff2test?
57
+
58
+ | Capability | **diff2test** | Manual Writing | Generic AI Chat |
59
+ |---|---|---|---|
60
+ | Scoped to actual PR / `git diff` | Yes | Manual | Manual copy-paste |
61
+ | Clones repo's existing test style | Yes (few-shot) | Yes | Rarely |
62
+ | Runs test suite & self-heals failures | Yes (up to 3x) | Manual | No |
63
+ | Hollow-test & assertion-drop guards | Yes | N/A | No |
64
+ | Zero-config GitHub Actions (`GITHUB_TOKEN`) | Yes (GitHub Models) | N/A | Requires external setup |
65
+ | Never overwrites existing test files | Yes | Manual | Risky |
66
+
67
+ ## Quick Start
68
+
69
+ ### GitHub Action (Zero-Secret Setup)
70
+
71
+ Create `.github/workflows/diff2test.yml` in your repository. No external API key is needed when using the default **GitHub Models** provider (`models: read` permission):
72
+
73
+ ```yaml
74
+ name: diff2test
75
+
76
+ on:
77
+ pull_request:
78
+ types: [opened, synchronize]
79
+
80
+ permissions:
81
+ contents: write # Needed when mode: commit
82
+ pull-requests: write # Needed to post/update the PR report comment
83
+ models: read # Needed for GitHub Models inference via GITHUB_TOKEN
84
+
85
+ jobs:
86
+ diff2test:
87
+ runs-on: ubuntu-latest
88
+ if: github.actor != 'github-actions[bot]'
89
+ steps:
90
+ - uses: actions/checkout@v4
91
+ with:
92
+ fetch-depth: 0
93
+ # For mode: commit, also add: ref: ${{ github.head_ref }}
94
+
95
+ - uses: mehmetakifkucukkaya/diff2test@v0
96
+ with:
97
+ mode: comment
98
+ ```
99
+
100
+ ### Local CLI
101
+
102
+ ```bash
103
+ pip install diff-to-test
104
+ # Optional: for Anthropic, Gemini, Bedrock, etc. via LiteLLM:
105
+ # pip install "diff-to-test[litellm]"
106
+
107
+ # Inspect detected framework, profile, and eligible diff files
108
+ diff2test detect --base origin/main
109
+
110
+ # Generate and verify tests for current branch changes
111
+ export GITHUB_TOKEN="your_token" # or DIFF2TEST_API_KEY / provider-specific env var
112
+ diff2test generate --base origin/main
113
+
114
+ # Create a commented .diff2test.yml template
115
+ diff2test init
116
+ ```
117
+
118
+ ## FAQ & Limitations
119
+
120
+ - **Privacy — what code is sent to the LLM?**
121
+ Only the filtered `git diff`, the changed source file(s), and up to 2 similar existing test files are sent to the provider you configure. For 100% local execution with zero external network calls, use `provider: ollama`.
122
+ - **Cost:**
123
+ Using the default `github` provider runs on GitHub Models via `GITHUB_TOKEN` (subject to GitHub Models rate limits). You can switch to any BYOK provider (`openai`, `deepseek`, `litellm`, `ollama`) at any time.
124
+ - **Supported Languages & Frameworks:**
125
+ Auto-detects `pytest` (`python-fastapi` / `generic`), `flutter test` (`flutter-widget`), `npm test`, `go test`, and `cargo test`. Additional frameworks can be added via [custom YAML profiles](docs/writing-profiles.md).
126
+ - **Known Limitations & Troubleshooting:**
127
+ - **Rate limits (`429`):** By default `fail-on-error` is `false`, so rate limits post a warning comment without breaking your PR. Switch `model` or configure a BYOK `api-key` if you hit GitHub Models quotas.
128
+ - **Fork PRs:** Pull requests from forks lack write tokens, so `mode: commit` automatically falls back to `mode: comment`.
129
+ - **Shallow clones:** `fetch-depth: 0` is recommended; if `fetch-depth: 1` is used, `diff2test` fetches the base branch as a fallback.
130
+
131
+ ## Documentation
132
+
133
+ - [Configuration Reference](docs/configuration.md)
134
+ - [Writing Custom Profiles](docs/writing-profiles.md)
135
+ - [Contributing Guide](CONTRIBUTING.md)
136
+ - [Security Policy](SECURITY.md)
137
+
138
+ ## License
139
+
140
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,26 @@
1
+ diff2test/__init__.py,sha256=Uxq_09eT9oLg0HAJ-wqQziqWU5QIxWqfV8sranSTiQA,105
2
+ diff2test/__main__.py,sha256=oUpK9vbppTbori2fn8OBklIg2FVCk7huj4C5J9et2II,114
3
+ diff2test/cli.py,sha256=QZtNbSKoz6Htnz3K_l0gAsxVaEoVxpWIznPWnwrMQWQ,14350
4
+ diff2test/config.py,sha256=uiXzzuX1hKjpjjV14ZBUqho5eq9x5psRBmZe7-rOFOs,7105
5
+ diff2test/context_builder.py,sha256=XuYOB_Y5d3mBZ-Yu96cYw3B7Ezth6jr_I0-91c_oetE,11940
6
+ diff2test/git_handler.py,sha256=X9NIwz11ansNzChDyPwtQafSOeqDsCN0HKG9w_glbD4,9085
7
+ diff2test/github_api.py,sha256=YjSYby17MiKdGUxhf-sm928VrZHTHJZZ-NESM6CJZoU,13912
8
+ diff2test/llm_client.py,sha256=VVF-srGae_u95UJBPI1rg1vYuwnfC2TZI9VLFyqzWP8,10635
9
+ diff2test/models.py,sha256=yYY2pcylvgei5yQNaS8hxOAQugKDwi92wsSRxwY55mg,2397
10
+ diff2test/pipeline.py,sha256=7JYnRE3dILLhOboct3UhKIhtClyV75GFBu_79PzW7YI,2581
11
+ diff2test/runner.py,sha256=4yp0if7UElUjCk2_jjfIzBQdTCZFPdk2dy0P95AoNcg,13329
12
+ diff2test/summary.py,sha256=KKgYXuS6rnVlernkB8r9ts5fyN9-eUx7gA4yFg4RYuo,703
13
+ diff2test/symbols.py,sha256=zpEcSut46VJCMMkgpbZIj-hhvEEvvzfTjtQ_d667kX8,3554
14
+ diff2test/profiles/__init__.py,sha256=ag8Bo36c02aq4-S_cmWhbauzD5mNJKTdujglaYwg-7M,4101
15
+ diff2test/profiles/dart-flutter.yaml,sha256=T05D7W4Ldh_F5ol1N-t4Nr4AvXvQh-AawFFTST8adE8,720
16
+ diff2test/profiles/generic.yaml,sha256=M5f_H5KPSJeOjbhqXdjVybZUYfgTMSARrwPdvL9EbSU,663
17
+ diff2test/profiles/python-fastapi.yaml,sha256=1IdqfTWF2JFr2q97hLLYe6toOF10Vn9d1OnRYaCUsko,746
18
+ diff2test/prompts/__init__.py,sha256=jZJzI9amd199tzqOk6km7tteKtS42P9obmHml_3nWi0,443
19
+ diff2test/prompts/fix.md,sha256=R57fs2oX5M5_Pn5JhP3_UO0DZZq9CBYyb2STyCc_Rbo,491
20
+ diff2test/prompts/generate.md,sha256=ifszWfpb3XFa0o3vcZsK1ToUTfBXmvsHRirA_rVDuZA,496
21
+ diff2test/prompts/system.md,sha256=cCwvKAfpikZwiGA5jcj7e8b45AgO8aSxvSEBgQDeFx4,665
22
+ diff_to_test-0.0.1.dist-info/METADATA,sha256=hhcbtjYGGXQdskddZm32X7wX01YLnKZ1xJ-YinM8X-s,6675
23
+ diff_to_test-0.0.1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
24
+ diff_to_test-0.0.1.dist-info/entry_points.txt,sha256=tAcPe9Zta0NGwk75AblAhhdHwZqv7fI7KOtd54kSGTQ,48
25
+ diff_to_test-0.0.1.dist-info/licenses/LICENSE,sha256=L_FQWZgpuDG5sA7nPxRWQ4cq8K-YksZPxFfz6cClKTs,1068
26
+ diff_to_test-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ diff2test = diff2test.cli:app
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mehmet Akif
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.