Registry / testing / pytest-picked

pytest-picked

JSON →
library0.5.1pypypi✓ verified 24d ago

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.

pip install pytest-picked
INSTALL
IMPORT
SIG · PYTEST-PICKED
P
pytest-picked
testingpythonv0.5.1
Install
2.7s avg
Import
Disk
30MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 31.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.7s · import 0.000s · 32MB
30MB installed
● package 30MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pytest-picked plugin
Functionality is exposed via the pytest command-line, e.g., 'pytest --picked'. No direct Python imports are typically used by end-users.
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.

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
pytest --version
Debug
Known issues
gotchaBy 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.
fix
Always specify the desired `--mode` and `--parent-branch` (if applicable) when you need to deviate from the default 'unstaged' change detection.
affects: All versions
gotcha`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.
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.
affects: All versions
compatibilityAs 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.
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.
affects: All versions
Upgrade
Version history
0.5.1latest on PyPI · released Nov 6, 2024
Audit
Dependencies
pytestrequiredpytest-picked is a plugin for the pytest testing framework and requires pytest to function.
pythonrequiredRequires Python 3.8 or higher as per PyPI metadata.
Agent activity
12 hits · last 30 days
node
8
Amazon
1
Resources
pytest-picked — pip install pytest-picked · libregistry