{"id":5432,"library":"pytest-picked","title":"pytest-picked","description":"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.","status":"active","version":"0.5.1","language":"en","source_language":"en","source_url":"https://github.com/anapaulagomes/pytest-picked","tags":["pytest","testing","git","developer-tools","ci-cd","code-quality"],"install":[{"cmd":"pip install pytest-picked","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"pytest-picked is a plugin for the pytest testing framework and requires pytest to function.","package":"pytest","optional":false},{"reason":"Requires Python 3.8 or higher as per PyPI metadata.","package":"python","optional":false}],"imports":[{"note":"pytest-picked is a plugin that extends the pytest test runner, so its features are accessed via command-line options or pytest configuration, rather than Python 'import' statements in test files.","symbol":"pytest-picked plugin","correct":"Functionality is exposed via the pytest command-line, e.g., 'pytest --picked'. No direct Python imports are typically used by end-users."}],"quickstart":{"code":"# 1. Install pytest-picked\n# pip install pytest-picked\n\n# 2. Create a test file (e.g., test_example.py)\n# def test_addition():\n#     assert 1 + 1 == 2\n#\n# def test_subtraction():\n#     assert 2 - 1 == 1\n\n# 3. Modify a test file (e.g., add a new test or change an existing one) and do not commit it.\n# For example, add the following to test_example.py:\n# def test_multiplication():\n#     assert 2 * 3 == 6\n\n# 4. Run pytest-picked to execute only the tests related to changed files\n# Navigate to your project's root directory in the terminal\n# Assuming test_example.py has unstaged changes:\n# pytest --picked\n\n# Example to run tests from modified files first, then all others:\n# pytest --picked=first\n\n# Example to run tests based on changes in the current branch compared to 'main':\n# pytest --picked --mode=branch --parent-branch=main","lang":"bash","description":"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."},"warnings":[{"fix":"Always specify the desired `--mode` and `--parent-branch` (if applicable) when you need to deviate from the default 'unstaged' change detection.","message":"By default, `pytest-picked` runs tests related to *unstaged* changes (`--mode=unstaged`). To run tests based on changes in a feature branch compared to a parent branch (e.g., `main`), users must explicitly use `--mode=branch` and optionally `--parent-branch`. Misunderstanding this default can lead to unexpected test selection.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your project is a Git repository, and that `git status` clearly shows the changes you expect `pytest-picked` to detect. Use Git commands to verify the state before running `pytest --picked` if unsure.","message":"`pytest-picked` relies on Git status to determine changed files. If Git is not initialized, if there are no detected changes according to Git, or if the repository state is unexpected (e.g., a dirty working tree preventing clear diffs), the plugin might not pick any tests, leading to an empty test run, or fall back to default `pytest` behavior, which can be confusing.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Before upgrading `pytest` to a new major version, check `pytest-picked`'s documentation or GitHub issues for known compatibility problems. Update `pytest-picked` to its latest version, if available, to ensure compatibility with newer `pytest` versions.","message":"As a `pytest` plugin, `pytest-picked`'s functionality is tightly coupled with `pytest` itself. Major upgrades of `pytest` can introduce breaking changes in its internal APIs or collection mechanisms, which might indirectly affect `pytest-picked` and require updates to the plugin to maintain compatibility.","severity":"compatibility","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}