pytest-deduplicate 0.1.4__tar.gz → 0.2.0__tar.gz

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.
Files changed (23) hide show
  1. pytest_deduplicate-0.2.0/PKG-INFO +221 -0
  2. pytest_deduplicate-0.2.0/README.md +187 -0
  3. {pytest_deduplicate-0.1.4 → pytest_deduplicate-0.2.0}/pyproject.toml +12 -6
  4. pytest_deduplicate-0.2.0/pytest_deduplicate.egg-info/PKG-INFO +221 -0
  5. {pytest_deduplicate-0.1.4 → pytest_deduplicate-0.2.0}/pytest_deduplicate.egg-info/SOURCES.txt +5 -0
  6. pytest_deduplicate-0.2.0/pytest_deduplicate.egg-info/requires.txt +9 -0
  7. pytest_deduplicate-0.2.0/pytest_deduplicate.egg-info/top_level.txt +6 -0
  8. pytest_deduplicate-0.2.0/pytest_deduplicate.py +613 -0
  9. pytest_deduplicate-0.2.0/pytest_deduplicate_artifacts.py +158 -0
  10. pytest_deduplicate-0.2.0/pytest_deduplicate_checks.py +394 -0
  11. pytest_deduplicate-0.2.0/pytest_deduplicate_import.py +215 -0
  12. pytest_deduplicate-0.2.0/pytest_deduplicate_index.py +32 -0
  13. pytest_deduplicate-0.2.0/pytest_deduplicate_review.py +90 -0
  14. pytest_deduplicate-0.1.4/PKG-INFO +0 -48
  15. pytest_deduplicate-0.1.4/README.md +0 -25
  16. pytest_deduplicate-0.1.4/pytest_deduplicate.egg-info/PKG-INFO +0 -48
  17. pytest_deduplicate-0.1.4/pytest_deduplicate.egg-info/requires.txt +0 -2
  18. pytest_deduplicate-0.1.4/pytest_deduplicate.egg-info/top_level.txt +0 -1
  19. pytest_deduplicate-0.1.4/pytest_deduplicate.py +0 -135
  20. {pytest_deduplicate-0.1.4 → pytest_deduplicate-0.2.0}/LICENSE +0 -0
  21. {pytest_deduplicate-0.1.4 → pytest_deduplicate-0.2.0}/pytest_deduplicate.egg-info/dependency_links.txt +0 -0
  22. {pytest_deduplicate-0.1.4 → pytest_deduplicate-0.2.0}/pytest_deduplicate.egg-info/entry_points.txt +0 -0
  23. {pytest_deduplicate-0.1.4 → pytest_deduplicate-0.2.0}/setup.cfg +0 -0
@@ -0,0 +1,221 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytest_deduplicate
3
+ Version: 0.2.0
4
+ Summary: Reports observed test coverage overlap with optional stability and mutation checks
5
+ Author-email: xor2003 <xor2003@gmx.com>
6
+ License: GPL
7
+ Project-URL: Homepage, https://github.com/xor2003/pytest_deduplicate
8
+ Keywords: duplicate test detection,test optimization,test efficiency
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Software Development :: Testing :: Unit
20
+ Classifier: Operating System :: OS Independent
21
+ Classifier: Topic :: Software Development :: Quality Assurance
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: pytest>=7.4.4
26
+ Requires-Dist: coverage>=7.6.1
27
+ Provides-Extra: dev
28
+ Requires-Dist: build>=1; extra == "dev"
29
+ Requires-Dist: wheel; extra == "dev"
30
+ Requires-Dist: hypothesis>=6.100; extra == "dev"
31
+ Requires-Dist: pytest-cov>=5; extra == "dev"
32
+ Requires-Dist: pytest-xdist>=3.6; extra == "dev"
33
+ Dynamic: license-file
34
+
35
+ # pytest_deduplicate
36
+
37
+ Review tests with identical or overlapping **observed branch coverage**, inspect the evidence, and optionally check stability and sampled fault detection.
38
+
39
+ Matching coverage does **not** prove equivalent assertions, inputs, side effects or testing value. Findings are review candidates, not instructions to delete tests.
40
+
41
+ ## Install and run
42
+
43
+ Requires Python 3.9+, pytest 7.4.4+ and coverage.py 7.6.1+.
44
+
45
+ ```sh
46
+ pip install .
47
+ pytest_deduplicate --source src --json overlap.json -q tests/
48
+ ```
49
+
50
+ From a source checkout you can also install `requirements.txt` and run:
51
+
52
+ ```sh
53
+ python /path/to/pytest_deduplicate.py --source src --json overlap.json -q tests/
54
+ ```
55
+
56
+ Run from the application project directory. `--source` accepts an existing file or directory and can be repeated. Explicit application scope prevents unrelated support/plugin activity from affecting comparisons. `--omit` accepts repeatable coverage.py glob patterns and is added to configured omissions:
57
+
58
+ ```sh
59
+ pytest_deduplicate --source src --source lib --omit '*/generated/*' --json overlap.json
60
+ ```
61
+
62
+ Without `--source`, coverage.py configuration/default scope applies. With explicit source paths, those paths replace configured source scope; other coverage filters still apply. The analyzer's own modules are always omitted.
63
+
64
+ Use `--deduplicate-help` for analyzer options. Unrecognized arguments are forwarded to pytest; `--help` remains pytest's help. Analyzer option names are reserved; put `--` before pytest arguments if a pytest plugin needs an option with the same name.
65
+
66
+ ## Understand the evidence
67
+
68
+ | Code | Meaning | Review question |
69
+ |---|---|---|
70
+ | W001 | Identical observed file-and-arc sets | Do the assertions protect different requirements or inputs? |
71
+ | W002 | Coverage contained in the union of smaller observations | What behavior does the larger test check that the combination does not? |
72
+ | W003 | Coverage contained in another observation | Does the smaller test catch faults that the larger one misses? |
73
+
74
+ Text output shows test identifiers, one-based locations, measured durations, shared/unique arc counts and file names. JSON also contains the exact shared and unique arcs, complete per-test observations, setup/call/teardown outcomes and timings, measurement scope and errors. The reports are independent candidates, not a coordinated removal plan or a minimal set cover.
75
+
76
+ `--json PATH` writes a versioned report and keeps normal text output. `--json -` writes only JSON to stdout, sending pytest output and check progress to stderr:
77
+
78
+ ```sh
79
+ pytest_deduplicate --source src --json - -q > overlap.json
80
+ ```
81
+
82
+ See [the JSON schema guide](docs/report-format.md).
83
+
84
+ ## Check stability
85
+
86
+ ```sh
87
+ pytest_deduplicate --source src --stability-runs 2 --seed 17 --json stability.json
88
+ ```
89
+
90
+ For each repetition, selected candidates run individually in fresh processes. When multiple candidates are selected, they also run together in original, reversed and seeded shuffled order. Coverage and phase outcomes are compared with the original full-suite observations; durations are not compared.
91
+
92
+ Results distinguish `stable_in_checked_runs`, `unstable` and `inconclusive`. A stable result covers only the checked scenarios. Tests that depend on an initializer outside the candidate set can fail when isolated; this is useful evidence of an order dependency, not a duplicate verdict.
93
+
94
+ `--max-candidates N` bounds optional checks (default 20). Selection prioritizes complete comparisons, new test modules, measured duration and overlap. Oversized identical groups can contribute useful pairs; combined comparisons stay whole. A budget of one selects no tests. `selection` records reasons and incomplete groups; unchecked tests are explicit. `--check-timeout SECONDS` bounds each fresh-process test invocation (default 30). Stability checks rerun tests in the current project and can repeat their normal side effects.
95
+
96
+ ## Sample fault detection (experimental)
97
+
98
+ ```sh
99
+ pytest_deduplicate --source src --mutations 10 --max-candidates 5 --json faults.json
100
+ ```
101
+
102
+ The seeded sampler distributes its budget across file/function/operator buckets and makes independent, single-line changes to arithmetic/comparison operators and integer/boolean constants on observed source lines. This is a bounded fault sample, not a complete mutation-testing engine or a mutmut integration.
103
+
104
+ Mutation sources must be inside the current project directory. The checker copies the project into a temporary directory, verifies each candidate against an unchanged copy, and runs each test/mutant trial in a fresh copy and process. Each mutant/test experiment repeats in a fresh copy at least twice (`--mutation-repeats`, default 2); differing repeated outcomes are inconclusive. `--mutation-snapshot-mb` (default 256) rejects oversized project copies before copying. The original source is never patched. Caches, virtual environments, build output and common metadata directories are excluded from copies. Tests that depend on these excluded files, external editable installations, or a different working directory may have inconclusive baselines. A temporary copy is not an OS security sandbox: tests retain their usual network and external-filesystem access.
105
+
106
+ For each mutant and test, JSON distinguishes `killed`, `survived`, `not_reached`, timeouts and errors. Only a failed test call that reached the mutation counts as a kill; collection/setup/teardown failures and timeouts do not. Per-pair comparisons identify distinguishing mutants. `same_on_sampled_mutants` means every sampled mutant was reached and produced the same conclusive outcome for both tests; it never establishes equivalence. Partial samples remain inconclusive.
107
+
108
+ Checks are skipped if the initial pytest run fails. Finding instability or different fault detection does not change a passing pytest exit code. Individual optional-check timeouts/errors appear as inconclusive evidence; an analyzer infrastructure failure produces a nonzero exit. Inspect the report when using optional checks in CI.
109
+
110
+ ## Collection and performance
111
+
112
+ The default `--collector contexts` keeps one coverage collector running and assigns explicit test node IDs as contexts. Both collector modes select coverage.py's tracing core: Python 3.14's default `sysmon` core does not support explicit context switching or the same complete arc observations. Setup, call and teardown have separate contexts attached to that test; inter-test activity uses an unqueried empty context. The previous `--collector restart` mode remains available for comparison.
113
+
114
+ ```sh
115
+ pytest_deduplicate --source src --benchmark-collectors 3 --json benchmark.json
116
+ ```
117
+
118
+ The benchmark reruns the selected suite in fresh processes with instrumentation disabled, with restart collection, and with context collection. Mode order rotates. It records raw wall times, medians, overhead relative to the uninstrumented pytest observer, and exact per-test coverage/outcome parity between instrumented modes. Benchmark parity includes repeated observations to expose unstable runs. Timings include interpreter/pytest startup. The tool does not automatically change collector settings.
119
+
120
+ The context default was selected after a bounded synthetic benchmark and regression checks for phase attribution. See [the recorded benchmark and reproduction command](docs/collector-benchmark.md). Measure your own suite before assuming the same improvement.
121
+
122
+ ## Conclusions and phase evidence
123
+
124
+ Each finding has one `assessment.status`: `unchecked`, `stable_coverage_only`,
125
+ `consistent_in_checked_sample`, `different_fault_detection`, `unstable`, or
126
+ `incomplete`. Full group membership matters: checking two tests in a larger
127
+ group does not validate the whole group. Pairwise mutant differences do not
128
+ prove anything about the fault-detection union of a combined finding. No status
129
+ authorizes automatic removal.
130
+
131
+ `tests[].phase_file_arcs` separates setup/call/teardown evidence. By default,
132
+ comparisons use all observed protocol activity. Use `--coverage-phase call` to
133
+ compare test calls without fixture setup/teardown. Shared fixtures remain
134
+ attributed only when executed; phases are not reconstructed for other tests.
135
+
136
+ ## Import pytest-cov and xdist results
137
+
138
+ Install pytest-cov and, for parallel runs, pytest-xdist. Record outcomes during
139
+ the **same fresh, non-append run**, then import without rerunning pytest:
140
+
141
+ ```sh
142
+ pytest -p pytest_deduplicate_import --cov=src --cov-branch --cov-context=test \
143
+ --deduplicate-outcomes outcomes.json -n 2 tests/
144
+ pytest_deduplicate --source src --import-coverage .coverage --outcomes outcomes.json \
145
+ --coverage-phase call --json overlap.json --html overlap.html
146
+ ```
147
+
148
+ `--deduplicate-coverage-file PATH` selects a nondefault final combined data file.
149
+ The companion selects a tracing core before pytest-cov starts, including on
150
+ Python 3.14 and xdist workers, and verifies the actual cores in the manifest.
151
+ It binds outcomes to the data file SHA-256, collected inventory, source/test
152
+ hashes and project root. Import rejects mismatches, missing phases, worker
153
+ failures, retries, stale contexts and line-only data. Import from the recorded
154
+ root before editing source. Missing explicit phase contexts are `null`, not
155
+ empty coverage: pytest-cov versions may attribute only calls. Such imports
156
+ remain incomplete for `--coverage-phase all`. Empty/unattributed contexts are
157
+ not assigned to tests. Import cannot run optional live checks.
158
+
159
+ ## Compare and review reports
160
+
161
+ ```sh
162
+ pytest_deduplicate --source src --json current.json --baseline previous.json \
163
+ --html overlap.html --review-template review-draft.json
164
+ ```
165
+
166
+ Finding IDs depend on kind and test IDs, not timings or commit paths. Baseline
167
+ comparison lists new, changed, unchanged and resolved findings. Resolution
168
+ requires successful runs with identical source scope and test inventory;
169
+ otherwise absent findings are `unobserved`. This supports reports from different
170
+ commits without claiming deselected tests have been fixed.
171
+
172
+ To record a reviewed finding, copy its template entry into a review document,
173
+ fill `reason` and `reviewed_at`, and pass `--suppressions reviews.json`. Empty
174
+ reasons are rejected. Source/test, arc, scope or assessment changes invalidate
175
+ the recorded evidence hash and mark it `needs_revalidation`. Reviewed entries
176
+ remain in JSON; the HTML viewer can hide only unchanged reviewed entries.
177
+
178
+ The standalone HTML report needs no server or external assets. Filter by module
179
+ or test, assessment and total observed duration; expand exact file/arc and
180
+ phase evidence. Source excerpts are embedded only when current bytes match the
181
+ report hash, capped at 500 lines per file. Displayed durations include coverage overhead and are not
182
+ predicted time savings.
183
+
184
+ ## Measured validation
185
+
186
+ [Real-project evaluation](docs/real-project-evaluation.md) covers bounded suites
187
+ in vextest (47 tests) and masm2c (20 tests), including manual counterexamples
188
+ and a random-order parser-cache effect. It does not establish whole-project
189
+ precision or semantic recall. Hypothesis tests compare set operations and
190
+ containment/combined detection with independent oracles and execute generated
191
+ programs with known findings.
192
+
193
+ The exact inverted arc index interns file/arc identities and filters impossible
194
+ comparisons. [Recorded analysis benchmark](docs/overlap-benchmark.json) and
195
+ `python tools/benchmark_overlap.py` compare it with the quadratic containment
196
+ oracle. Dense findings can still require quadratic output; no findings are
197
+ silently dropped.
198
+
199
+ ## Remaining limits
200
+
201
+ - Coverage records Python line transitions, not values, assertions, execution counts, complete paths or native-code behavior.
202
+ - Collected Python test bodies (including nested code) are excluded, but helpers/fixtures in those files remain measurable. Custom collectors or decorators without inspectable wrapped functions may retain test scaffolding.
203
+ - Only fully passed, non-xfail tests with nonempty observations become candidates. JSON still records other test outcomes and available coverage.
204
+ - Shared fixtures and caches can make observations order dependent. A module/session fixture is attributed only to the test during which pytest actually executes its setup or teardown.
205
+ - Live collection requires one serial pytest process and rejects simultaneous `--cov`. Existing pytest-cov/xdist data can be imported with the companion manifest below. Arbitrary subprocess coverage and externally active collectors are not validated.
206
+ - Repeated execution of the same node ID within a run (for example rerun plugins) is not supported. Do not combine this tool with retries.
207
+ - Test durations include instrumentation overhead. Comparison analysis can become expensive for many distinct coverage sets; optional checks are bounded separately.
208
+
209
+ ## Development and release checks
210
+
211
+ ```sh
212
+ python -m pip install -r requirements.txt build wheel setuptools "hypothesis>=6.100" "pytest-cov>=5" "pytest-xdist>=3.6"
213
+ python -m pytest -q
214
+ python tools/check_distribution.py
215
+ ```
216
+
217
+ CI covers Python 3.9–3.14, minimum/current dependency combinations, and a Windows job. The distribution check builds an sdist and a wheel from the sdist, installs that wheel in a temporary environment, verifies imports come from the installed distribution, and exercises its command, optional checks and failure exit status outside the checkout.
218
+
219
+ The build checker stages an explicit set of release files, excluding unrelated local Cython experiments and untracked `setup.py` files. If such an experimental setup script is present in your working directory, use the checker for release validation; a direct `pip install .` can invoke that script. The committed project uses the pure-Python modules declared in `pyproject.toml`.
220
+
221
+ Python 3.8 is no longer advertised: the original runtime type aliases already required 3.9, and the mutation sampler now explicitly uses Python 3.9's AST support.
@@ -0,0 +1,187 @@
1
+ # pytest_deduplicate
2
+
3
+ Review tests with identical or overlapping **observed branch coverage**, inspect the evidence, and optionally check stability and sampled fault detection.
4
+
5
+ Matching coverage does **not** prove equivalent assertions, inputs, side effects or testing value. Findings are review candidates, not instructions to delete tests.
6
+
7
+ ## Install and run
8
+
9
+ Requires Python 3.9+, pytest 7.4.4+ and coverage.py 7.6.1+.
10
+
11
+ ```sh
12
+ pip install .
13
+ pytest_deduplicate --source src --json overlap.json -q tests/
14
+ ```
15
+
16
+ From a source checkout you can also install `requirements.txt` and run:
17
+
18
+ ```sh
19
+ python /path/to/pytest_deduplicate.py --source src --json overlap.json -q tests/
20
+ ```
21
+
22
+ Run from the application project directory. `--source` accepts an existing file or directory and can be repeated. Explicit application scope prevents unrelated support/plugin activity from affecting comparisons. `--omit` accepts repeatable coverage.py glob patterns and is added to configured omissions:
23
+
24
+ ```sh
25
+ pytest_deduplicate --source src --source lib --omit '*/generated/*' --json overlap.json
26
+ ```
27
+
28
+ Without `--source`, coverage.py configuration/default scope applies. With explicit source paths, those paths replace configured source scope; other coverage filters still apply. The analyzer's own modules are always omitted.
29
+
30
+ Use `--deduplicate-help` for analyzer options. Unrecognized arguments are forwarded to pytest; `--help` remains pytest's help. Analyzer option names are reserved; put `--` before pytest arguments if a pytest plugin needs an option with the same name.
31
+
32
+ ## Understand the evidence
33
+
34
+ | Code | Meaning | Review question |
35
+ |---|---|---|
36
+ | W001 | Identical observed file-and-arc sets | Do the assertions protect different requirements or inputs? |
37
+ | W002 | Coverage contained in the union of smaller observations | What behavior does the larger test check that the combination does not? |
38
+ | W003 | Coverage contained in another observation | Does the smaller test catch faults that the larger one misses? |
39
+
40
+ Text output shows test identifiers, one-based locations, measured durations, shared/unique arc counts and file names. JSON also contains the exact shared and unique arcs, complete per-test observations, setup/call/teardown outcomes and timings, measurement scope and errors. The reports are independent candidates, not a coordinated removal plan or a minimal set cover.
41
+
42
+ `--json PATH` writes a versioned report and keeps normal text output. `--json -` writes only JSON to stdout, sending pytest output and check progress to stderr:
43
+
44
+ ```sh
45
+ pytest_deduplicate --source src --json - -q > overlap.json
46
+ ```
47
+
48
+ See [the JSON schema guide](docs/report-format.md).
49
+
50
+ ## Check stability
51
+
52
+ ```sh
53
+ pytest_deduplicate --source src --stability-runs 2 --seed 17 --json stability.json
54
+ ```
55
+
56
+ For each repetition, selected candidates run individually in fresh processes. When multiple candidates are selected, they also run together in original, reversed and seeded shuffled order. Coverage and phase outcomes are compared with the original full-suite observations; durations are not compared.
57
+
58
+ Results distinguish `stable_in_checked_runs`, `unstable` and `inconclusive`. A stable result covers only the checked scenarios. Tests that depend on an initializer outside the candidate set can fail when isolated; this is useful evidence of an order dependency, not a duplicate verdict.
59
+
60
+ `--max-candidates N` bounds optional checks (default 20). Selection prioritizes complete comparisons, new test modules, measured duration and overlap. Oversized identical groups can contribute useful pairs; combined comparisons stay whole. A budget of one selects no tests. `selection` records reasons and incomplete groups; unchecked tests are explicit. `--check-timeout SECONDS` bounds each fresh-process test invocation (default 30). Stability checks rerun tests in the current project and can repeat their normal side effects.
61
+
62
+ ## Sample fault detection (experimental)
63
+
64
+ ```sh
65
+ pytest_deduplicate --source src --mutations 10 --max-candidates 5 --json faults.json
66
+ ```
67
+
68
+ The seeded sampler distributes its budget across file/function/operator buckets and makes independent, single-line changes to arithmetic/comparison operators and integer/boolean constants on observed source lines. This is a bounded fault sample, not a complete mutation-testing engine or a mutmut integration.
69
+
70
+ Mutation sources must be inside the current project directory. The checker copies the project into a temporary directory, verifies each candidate against an unchanged copy, and runs each test/mutant trial in a fresh copy and process. Each mutant/test experiment repeats in a fresh copy at least twice (`--mutation-repeats`, default 2); differing repeated outcomes are inconclusive. `--mutation-snapshot-mb` (default 256) rejects oversized project copies before copying. The original source is never patched. Caches, virtual environments, build output and common metadata directories are excluded from copies. Tests that depend on these excluded files, external editable installations, or a different working directory may have inconclusive baselines. A temporary copy is not an OS security sandbox: tests retain their usual network and external-filesystem access.
71
+
72
+ For each mutant and test, JSON distinguishes `killed`, `survived`, `not_reached`, timeouts and errors. Only a failed test call that reached the mutation counts as a kill; collection/setup/teardown failures and timeouts do not. Per-pair comparisons identify distinguishing mutants. `same_on_sampled_mutants` means every sampled mutant was reached and produced the same conclusive outcome for both tests; it never establishes equivalence. Partial samples remain inconclusive.
73
+
74
+ Checks are skipped if the initial pytest run fails. Finding instability or different fault detection does not change a passing pytest exit code. Individual optional-check timeouts/errors appear as inconclusive evidence; an analyzer infrastructure failure produces a nonzero exit. Inspect the report when using optional checks in CI.
75
+
76
+ ## Collection and performance
77
+
78
+ The default `--collector contexts` keeps one coverage collector running and assigns explicit test node IDs as contexts. Both collector modes select coverage.py's tracing core: Python 3.14's default `sysmon` core does not support explicit context switching or the same complete arc observations. Setup, call and teardown have separate contexts attached to that test; inter-test activity uses an unqueried empty context. The previous `--collector restart` mode remains available for comparison.
79
+
80
+ ```sh
81
+ pytest_deduplicate --source src --benchmark-collectors 3 --json benchmark.json
82
+ ```
83
+
84
+ The benchmark reruns the selected suite in fresh processes with instrumentation disabled, with restart collection, and with context collection. Mode order rotates. It records raw wall times, medians, overhead relative to the uninstrumented pytest observer, and exact per-test coverage/outcome parity between instrumented modes. Benchmark parity includes repeated observations to expose unstable runs. Timings include interpreter/pytest startup. The tool does not automatically change collector settings.
85
+
86
+ The context default was selected after a bounded synthetic benchmark and regression checks for phase attribution. See [the recorded benchmark and reproduction command](docs/collector-benchmark.md). Measure your own suite before assuming the same improvement.
87
+
88
+ ## Conclusions and phase evidence
89
+
90
+ Each finding has one `assessment.status`: `unchecked`, `stable_coverage_only`,
91
+ `consistent_in_checked_sample`, `different_fault_detection`, `unstable`, or
92
+ `incomplete`. Full group membership matters: checking two tests in a larger
93
+ group does not validate the whole group. Pairwise mutant differences do not
94
+ prove anything about the fault-detection union of a combined finding. No status
95
+ authorizes automatic removal.
96
+
97
+ `tests[].phase_file_arcs` separates setup/call/teardown evidence. By default,
98
+ comparisons use all observed protocol activity. Use `--coverage-phase call` to
99
+ compare test calls without fixture setup/teardown. Shared fixtures remain
100
+ attributed only when executed; phases are not reconstructed for other tests.
101
+
102
+ ## Import pytest-cov and xdist results
103
+
104
+ Install pytest-cov and, for parallel runs, pytest-xdist. Record outcomes during
105
+ the **same fresh, non-append run**, then import without rerunning pytest:
106
+
107
+ ```sh
108
+ pytest -p pytest_deduplicate_import --cov=src --cov-branch --cov-context=test \
109
+ --deduplicate-outcomes outcomes.json -n 2 tests/
110
+ pytest_deduplicate --source src --import-coverage .coverage --outcomes outcomes.json \
111
+ --coverage-phase call --json overlap.json --html overlap.html
112
+ ```
113
+
114
+ `--deduplicate-coverage-file PATH` selects a nondefault final combined data file.
115
+ The companion selects a tracing core before pytest-cov starts, including on
116
+ Python 3.14 and xdist workers, and verifies the actual cores in the manifest.
117
+ It binds outcomes to the data file SHA-256, collected inventory, source/test
118
+ hashes and project root. Import rejects mismatches, missing phases, worker
119
+ failures, retries, stale contexts and line-only data. Import from the recorded
120
+ root before editing source. Missing explicit phase contexts are `null`, not
121
+ empty coverage: pytest-cov versions may attribute only calls. Such imports
122
+ remain incomplete for `--coverage-phase all`. Empty/unattributed contexts are
123
+ not assigned to tests. Import cannot run optional live checks.
124
+
125
+ ## Compare and review reports
126
+
127
+ ```sh
128
+ pytest_deduplicate --source src --json current.json --baseline previous.json \
129
+ --html overlap.html --review-template review-draft.json
130
+ ```
131
+
132
+ Finding IDs depend on kind and test IDs, not timings or commit paths. Baseline
133
+ comparison lists new, changed, unchanged and resolved findings. Resolution
134
+ requires successful runs with identical source scope and test inventory;
135
+ otherwise absent findings are `unobserved`. This supports reports from different
136
+ commits without claiming deselected tests have been fixed.
137
+
138
+ To record a reviewed finding, copy its template entry into a review document,
139
+ fill `reason` and `reviewed_at`, and pass `--suppressions reviews.json`. Empty
140
+ reasons are rejected. Source/test, arc, scope or assessment changes invalidate
141
+ the recorded evidence hash and mark it `needs_revalidation`. Reviewed entries
142
+ remain in JSON; the HTML viewer can hide only unchanged reviewed entries.
143
+
144
+ The standalone HTML report needs no server or external assets. Filter by module
145
+ or test, assessment and total observed duration; expand exact file/arc and
146
+ phase evidence. Source excerpts are embedded only when current bytes match the
147
+ report hash, capped at 500 lines per file. Displayed durations include coverage overhead and are not
148
+ predicted time savings.
149
+
150
+ ## Measured validation
151
+
152
+ [Real-project evaluation](docs/real-project-evaluation.md) covers bounded suites
153
+ in vextest (47 tests) and masm2c (20 tests), including manual counterexamples
154
+ and a random-order parser-cache effect. It does not establish whole-project
155
+ precision or semantic recall. Hypothesis tests compare set operations and
156
+ containment/combined detection with independent oracles and execute generated
157
+ programs with known findings.
158
+
159
+ The exact inverted arc index interns file/arc identities and filters impossible
160
+ comparisons. [Recorded analysis benchmark](docs/overlap-benchmark.json) and
161
+ `python tools/benchmark_overlap.py` compare it with the quadratic containment
162
+ oracle. Dense findings can still require quadratic output; no findings are
163
+ silently dropped.
164
+
165
+ ## Remaining limits
166
+
167
+ - Coverage records Python line transitions, not values, assertions, execution counts, complete paths or native-code behavior.
168
+ - Collected Python test bodies (including nested code) are excluded, but helpers/fixtures in those files remain measurable. Custom collectors or decorators without inspectable wrapped functions may retain test scaffolding.
169
+ - Only fully passed, non-xfail tests with nonempty observations become candidates. JSON still records other test outcomes and available coverage.
170
+ - Shared fixtures and caches can make observations order dependent. A module/session fixture is attributed only to the test during which pytest actually executes its setup or teardown.
171
+ - Live collection requires one serial pytest process and rejects simultaneous `--cov`. Existing pytest-cov/xdist data can be imported with the companion manifest below. Arbitrary subprocess coverage and externally active collectors are not validated.
172
+ - Repeated execution of the same node ID within a run (for example rerun plugins) is not supported. Do not combine this tool with retries.
173
+ - Test durations include instrumentation overhead. Comparison analysis can become expensive for many distinct coverage sets; optional checks are bounded separately.
174
+
175
+ ## Development and release checks
176
+
177
+ ```sh
178
+ python -m pip install -r requirements.txt build wheel setuptools "hypothesis>=6.100" "pytest-cov>=5" "pytest-xdist>=3.6"
179
+ python -m pytest -q
180
+ python tools/check_distribution.py
181
+ ```
182
+
183
+ CI covers Python 3.9–3.14, minimum/current dependency combinations, and a Windows job. The distribution check builds an sdist and a wheel from the sdist, installs that wheel in a temporary environment, verifies imports come from the installed distribution, and exercises its command, optional checks and failure exit status outside the checkout.
184
+
185
+ The build checker stages an explicit set of release files, excluding unrelated local Cython experiments and untracked `setup.py` files. If such an experimental setup script is present in your working directory, use the checker for release validation; a direct `pip install .` can invoke that script. The committed project uses the pure-Python modules declared in `pyproject.toml`.
186
+
187
+ Python 3.8 is no longer advertised: the original runtime type aliases already required 3.9, and the mutation sampler now explicitly uses Python 3.9's AST support.
@@ -4,16 +4,16 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pytest_deduplicate"
7
- version = "0.1.4"
8
- description = "Identifies duplicate unit tests"
7
+ version = "0.2.0"
8
+ description = "Reports observed test coverage overlap with optional stability and mutation checks"
9
9
  authors = [
10
10
  {name = "xor2003", email = "xor2003@gmx.com"},
11
11
  ]
12
- dependencies = ["pytest","coverage"]
13
- requires-python = ">=3.8"
12
+ dependencies = ["pytest>=7.4.4", "coverage>=7.6.1"]
13
+ requires-python = ">=3.9"
14
14
  readme = "README.md"
15
15
  license = {text = "GPL"}
16
- keywords = ["pytest", "deduplicate"]
16
+ keywords = ["duplicate test detection","test optimization", "test efficiency"]
17
17
  classifiers = [
18
18
  "Development Status :: 4 - Beta",
19
19
  "Intended Audience :: Developers",
@@ -21,8 +21,10 @@ classifiers = [
21
21
  "Programming Language :: Python :: 3",
22
22
  "Programming Language :: Python :: 3.10",
23
23
  "Programming Language :: Python :: 3.11",
24
- "Programming Language :: Python :: 3.8",
25
24
  "Programming Language :: Python :: 3.9",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13",
27
+ "Programming Language :: Python :: 3.14",
26
28
  "Topic :: Software Development :: Testing :: Unit",
27
29
  "Operating System :: OS Independent",
28
30
  "Topic :: Software Development :: Quality Assurance"
@@ -37,6 +39,10 @@ tag-date = 0
37
39
 
38
40
  [tool.setuptools]
39
41
  include-package-data = false
42
+ py-modules = ["pytest_deduplicate", "pytest_deduplicate_checks", "pytest_deduplicate_review", "pytest_deduplicate_import", "pytest_deduplicate_index", "pytest_deduplicate_artifacts"]
40
43
 
41
44
  [project.scripts]
42
45
  pytest_deduplicate = "pytest_deduplicate:main"
46
+
47
+ [project.optional-dependencies]
48
+ dev = ["build>=1", "wheel", "hypothesis>=6.100", "pytest-cov>=5", "pytest-xdist>=3.6"]