pytest-picked

0.5.1 · active · verified Mon Apr 13

pytest-picked is a pytest plugin (version 0.5.1) that enhances test execution by allowing users to run only the tests related to files changed according to Git. It's currently active and maintained, with releases on PyPI. This helps developers quickly test relevant code without running the entire test suite, particularly useful in continuous integration or local development workflows.

Warnings

Install

Imports

Quickstart

After installation, `pytest-picked` integrates with the `pytest` command. You run tests by invoking `pytest` with the `--picked` flag. By default, it runs tests from files with unstaged changes. You can specify different modes (e.g., `--mode=branch`) and a parent branch (`--parent-branch`) for more advanced selection based on Git history.

# 1. Install pytest-picked
# pip install pytest-picked

# 2. Create a test file (e.g., test_example.py)
# def test_addition():
#     assert 1 + 1 == 2
#
# def test_subtraction():
#     assert 2 - 1 == 1

# 3. Modify a test file (e.g., add a new test or change an existing one) and do not commit it.
# For example, add the following to test_example.py:
# def test_multiplication():
#     assert 2 * 3 == 6

# 4. Run pytest-picked to execute only the tests related to changed files
# Navigate to your project's root directory in the terminal
# Assuming test_example.py has unstaged changes:
# pytest --picked

# Example to run tests from modified files first, then all others:
# pytest --picked=first

# Example to run tests based on changes in the current branch compared to 'main':
# pytest --picked --mode=branch --parent-branch=main

view raw JSON →