pytest-shard

0.1.2 · maintenance · verified Sat Apr 11

pytest-shard is a pytest plugin (version 0.1.2) designed to parallelize test execution across multiple machines by sharding tests based on a hash of their test names. It enables fine-grained parallelism at the individual test case level, making it suitable for various continuous integration (CI) services. The library appears to be in a maintenance phase, with the last PyPI update in December 2020.

Warnings

Install

Imports

Quickstart

After installation, pytest-shard is enabled by passing `--shard-id` and `--num-shards` arguments to the `pytest` command. `--shard-id` specifies the index of the current shard (0-indexed), and `--num-shards` specifies the total number of shards. This is typically configured in CI pipelines where tests are distributed across parallel jobs.

# Example: Shard tests across two machines
# On machine 1:
pytest --shard-id=0 --num-shards=2

# On machine 2:
pytest --shard-id=1 --num-shards=2

# Example for CircleCI:
pytest --shard-id=${CIRCLE_NODE_INDEX} --num-shards=${CIRCLE_NODE_TOTAL}

view raw JSON →