Metadata-Version: 2.1
Name: pytest-git-diff
Version: 1.0.0
Summary: Pytest plugin that allows the user to select the tests affected by a range of git commits
Home-page: https://github.com/sponja23/pytest-git-diff
License: MIT
Author: sponja23
Author-email: tomas.spognardi@gmail.com
Requires-Python: >=3.8,<4.0
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Testing
Requires-Dist: pydeps (>=1.12.19,<2.0.0)
Project-URL: Repository, https://github.com/sponja23/pytest-git-diff
Description-Content-Type: text/markdown

# pytest-git-diff

Pytest plugin that allows the user to select the tests *affected* by a given range of git commits. A file is considered affected when:
- It was added/modified in between the commits.
- It imports another affected file.

## Installation

```bash
pip install pytest-git-diff
```

## Usage

This plugin adds 2 options to the `pytest` CLI:
- `--only-affected-by`: filters the collected tests, keeping only those affected by the given commit range. This range should be in the format `FROM_REV..TO_REV`. If `TO_REV` is omitted, it defaults to 'HEAD'.
- `--only-affected-last-commit`: has the same effect as `--only-affected-by=HEAD~1..HEAD`.

## Limitations

The main limitation in this plugin is that file paths must be valid Python identifier names (in particular, they can't contain dashes). That applies to every part of the path up to the working directory in which `pytest` was invoked.

This issue stems from a problem in the `pydeps` dependency. See https://github.com/thebjorn/pydeps/issues/24.

