Skip to main content

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

  1. 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
    
  2. Run the smoke suite: Use the --smoke flag 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

  1. Profiling: It runs your suite with pytest-cov and a custom hook to map every single branch execution to specific tests.
  2. Analysis: It calculates the "efficiency" of every test (New Branches Covered / Duration).
  3. Greedy Selection: It iteratively picks the most efficient test until your coverage target or time cap is reached.
  4. Redundancy Reporting: It identifies "Coverage-equivalent groups" — sets of tests that cover the exact same logic.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smoke_optimiser-0.1.0.tar.gz (23.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smoke_optimiser-0.1.0-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

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

Hashes for smoke_optimiser-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f36bd55580b8a5e5b1bc1825ce7f368c02b02207ef19e5fb70df680ff865ed60
MD5 5e0ed254a71be2d82a8e998111e248f6
BLAKE2b-256 1bc530357845d09d882aaf71cd4f6451ea14e7bcea48a3121e786241f63fb172

See more details on using hashes here.

Provenance

The following attestation bundles were made for smoke_optimiser-0.1.0.tar.gz:

Publisher: release.yml on lawther/smoke-optimiser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for smoke_optimiser-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 248ecedfd66be9cba58886d8bf79268d5fc45277bdac1a1492e1aa89cb9f2166
MD5 f0c461a9037ac6aeaa4b4225418d05e2
BLAKE2b-256 61b79c1bed3cd33eee68f6d9a077456c2b92af3c0a138b39651d39556cd5c817

See more details on using hashes here.

Provenance

The following attestation bundles were made for smoke_optimiser-0.1.0-py3-none-any.whl:

Publisher: release.yml on lawther/smoke-optimiser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page