Skip to main content

Run tests covering a specific file or changeset

Project description

PyPI version Python versions See Build Status on Travis CI See Build Status on AppVeyor

pytest-involve is a pytest plugin for running only tests which cover a given file or set of files. It’s called pytest-involve because it lets you run only tests involving modules or members from those modules.

Usually with pytest the test set to run is specified and coverage collected based on that set. When pytest-involve is used, instead you specify the file(s) you want to cover, and test files are selected based on whether they import from those file(s) or not.


pytest-involve adds one command line argument to pytest, namely --involving. This can be provided a file path, a module import path (such as you would use in a Python interpreter), or either of the above suffixed with :: and the name of something defined in there:

pytest --involving ./path/to/

pytest --involving importable.module.path

pytest --involving ./path/to/

pytest --involving importable.module.path::member

This will have the effect of only collecting and running tests which are defined in modules whose imports overlap with the file(s) and member(s) specified with the --involving flag.

The plugin aims for recall over precision: It might run a few tests that aren’t strictly necessary, but it shouldn’t ignore any tests that are.

The ::member syntax will only work for things with a __file__ attribute (so, mostly classes and functions).

pytest-involve should play nicely with most other pytest plugins.

This pytest plugin was generated with Cookiecutter along with @hackebrot’s cookiecutter-pytest-plugin template.


  • Run unit tests covering specific file(s) via the command line flag --involving


  • pytest

  • That’s it.


You can install “pytest-involve” via pip from PyPI:

$ pip install pytest-involve


Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.


Distributed under the terms of the MIT license, “pytest-involve” is free and open source software.


If you encounter any problems, please file an issue along with a detailed description.

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

pytest-involve-0.1.0.tar.gz (7.4 kB view hashes)

Uploaded Source

Built Distribution

pytest_involve-0.1.0-py3-none-any.whl (7.5 kB view hashes)

Uploaded Python 3

Supported by

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