Skip to main content

pytest-incremental

an incremental test runner (pytest plugin)

What is an “incremental test runner” ?

When talking about build-tools it is common to refer to the terms:

  • initial (full) build - all files are compiled

  • incremental build (or partial rebuild) - just changed files are compiled

  • no-op build - no files are compiled (none changed since last execution)

So an “incremental test runner” will only re-execute tests that were affected by changes in the source code since last test execution.

How it works ?

pytest-incremental is a pytest plugin. So if you can run your test suite with pytest you can use pytest-incremental.

The plugin will analyse your python source files and through its imports define the dependencies of the modules. doit is used to keep track of the dependencies and save results. The plugin will modify how pytest collect your tests. pytest do the rest of the job of actually running the tests and reporting the results.

Install

pytest-incremental is tested on python 2.6, 2.7.

pip install pytest-incremental`

python setup.py install

local installation

You can also just grab the plugin module file and put in your project path. Then enable it (check pytest docs).

Usage

Just pass the parameter --incremental when calling from the command line:

$ py.test --incremental

You can also enable it by default adding the following line to your pytest.ini:

[pytest]
addopts = --incremental

watched packages

By default all modules collected by pytest will used as dependencies if imported. In order to limit or extend the watched folders you must use the parameter --watch-pkg

Limitations

pytest-incremental looks for imports recursively to find dependencies (using AST). But given the very dynamic nature of python there are still some cases that a module can be affected by a module that are not detected.

  • from package import * modules imported from __all__ in a package are not counted as a dependency

  • modules imported not using the import statement

  • modules not explictitly imported but used at runtime (i.e. conftest.py when running your tests with pytest)

  • monkey-patching. (i.e. A imports X. B monkey-patches X. In this case A might depend on B)

  • others ?

Project Details

Metadata

Release files for pytest-incremental 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-incremental 0.1.0
File Size Uploaded
pytest-incremental-0.1.0.tar.gz 6.4 kB Details

Release files / pytest-incremental-0.1.0.tar.gz

Download URL pytest-incremental-0.1.0.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7bd01dcc9d12de7478f0722e2d81e0807330b9b0fd5264e6c6b7575a09d14bbe
BLAKE2b-256 checksum
How to use checksums
5a128bad8b1a2db16b89ef50859eac1d7c136d4226f03f04c45a94b5bd714705
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.6.0

1 release file

0.5.0

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page