A Python CLI tool and pytest plugin to identify and run a minimal smoke test suite.
Project description
smoke-optimiser
smoke-optimiser is a tool and pytest plugin that analyses your test suite to produce a minimal smoke suite — a subset of tests that delivers maximum code coverage in minimum wall-clock time.
It helps you find the "bang for buck" sweet spot: for example, achieving 80% of your total branch coverage in only 5% of the total runtime.
Installation
Add smoke-optimiser as a development dependency in your project:
uv add --dev smoke-optimiser
Or with pip:
pip install smoke-optimiser
This will make the smoke-optimiser command available in your environment and register the pytest plugin automatically.
Quickstart
-
Generate the smoke suite: Run the optimiser in your project root. It will automatically detect your source code and profile your tests.
uv run smoke-optimiser
-
Run the smoke suite: Use the
--smokeflag with pytest to run only the selected high-value tests.uv run pytest --smoke
Common Usages
Custom Efficiency Targets
By default, the tool tries to get maximum coverage within a 15-second time cap. You can tighten these bounds:
# Aim for 80% coverage, but stop if it takes longer than 5 seconds
uv run smoke-optimiser --target-cov=80 --time-cap=5
Stabilising Timing Data
Test execution times can vary. Use --iterations to run the suite multiple times and average the results for a more stable smoke suite:
uv run smoke-optimiser --iterations=3
Mandatory Inclusion/Exclusion
Force certain tests (or markers) to be included or excluded from the smoke suite:
# Always include authentication tests, but exclude anything marked as 'slow'
uv run smoke-optimiser --include="tests/test_auth.py" --exclude="@pytest.mark.slow"
Multiple items can be separated by commas.
Command-line Arguments
smoke-optimiser (Generator)
| Argument | Description | Default |
|---|---|---|
--src |
The source directory or package to measure coverage for. | Discovered |
--iterations |
Number of times to run profiling to average timing data. | 1 |
--time-cap |
Maximum wall-clock runtime (seconds) of the smoke suite. | 15.0 |
--target-cov |
Target % of the full suite's branch coverage to achieve. | 100.0 |
--include |
Comma-separated list of tests, files, or markers to force include. | [] |
--exclude |
Comma-separated list of tests, files, or markers to force exclude. | [] |
--pytest-args |
Extra arguments forwarded to pytest during profiling. | "" |
--output-json |
Path for the generated smoke suite definition file. | .smoke_suite.json |
--profile-only |
Run only the profiling phase and save intermediate data. | False |
--optimise-only |
Run only the optimisation phase using existing profile data. | False |
--allow-ordered |
Suppress warning when pytest-randomly is not installed. |
False |
pytest (Plugin)
| Argument | Description | Default |
|---|---|---|
--smoke |
Activates the plugin; filters collection to the smoke suite. | False |
--smoke-file-path |
Path to the smoke suite JSON file to use. | .smoke_suite.json |
How it works
- Profiling: It runs your suite with
pytest-covand a custom hook to map every single branch execution to specific tests. - Analysis: It calculates the "efficiency" of every test (New Branches Covered / Duration).
- Greedy Selection: It iteratively picks the most efficient test until your coverage target or time cap is reached.
- Redundancy Reporting: It identifies "Coverage-equivalent groups" — sets of tests that cover the exact same logic.
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 smoke_optimiser-0.1.0.tar.gz.
File metadata
- Download URL: smoke_optimiser-0.1.0.tar.gz
- Upload date:
- Size: 23.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f36bd55580b8a5e5b1bc1825ce7f368c02b02207ef19e5fb70df680ff865ed60
|
|
| MD5 |
5e0ed254a71be2d82a8e998111e248f6
|
|
| BLAKE2b-256 |
1bc530357845d09d882aaf71cd4f6451ea14e7bcea48a3121e786241f63fb172
|
Provenance
The following attestation bundles were made for smoke_optimiser-0.1.0.tar.gz:
Publisher:
release.yml on lawther/smoke-optimiser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smoke_optimiser-0.1.0.tar.gz -
Subject digest:
f36bd55580b8a5e5b1bc1825ce7f368c02b02207ef19e5fb70df680ff865ed60 - Sigstore transparency entry: 1396113892
- Sigstore integration time:
-
Permalink:
lawther/smoke-optimiser@ef5e0985a525a3850a342766a02f93c13393ee4b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/lawther
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ef5e0985a525a3850a342766a02f93c13393ee4b -
Trigger Event:
push
-
Statement type:
File details
Details for the file smoke_optimiser-0.1.0-py3-none-any.whl.
File metadata
- Download URL: smoke_optimiser-0.1.0-py3-none-any.whl
- Upload date:
- Size: 26.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
248ecedfd66be9cba58886d8bf79268d5fc45277bdac1a1492e1aa89cb9f2166
|
|
| MD5 |
f0c461a9037ac6aeaa4b4225418d05e2
|
|
| BLAKE2b-256 |
61b79c1bed3cd33eee68f6d9a077456c2b92af3c0a138b39651d39556cd5c817
|
Provenance
The following attestation bundles were made for smoke_optimiser-0.1.0-py3-none-any.whl:
Publisher:
release.yml on lawther/smoke-optimiser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
smoke_optimiser-0.1.0-py3-none-any.whl -
Subject digest:
248ecedfd66be9cba58886d8bf79268d5fc45277bdac1a1492e1aa89cb9f2166 - Sigstore transparency entry: 1396113914
- Sigstore integration time:
-
Permalink:
lawther/smoke-optimiser@ef5e0985a525a3850a342766a02f93c13393ee4b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/lawther
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ef5e0985a525a3850a342766a02f93c13393ee4b -
Trigger Event:
push
-
Statement type: