Skip to main content

a pytest plugin for parallel and concurrent testing

Project description

pytest-parallel

a pytest plugin for parallel and concurrent testing

What?

This plugin makes it possible to run tests quickly using multiprocessing (parallelism) and multithreading (concurrency).

Why?

pytest-xdist is great to run tests that:

  1. aren't threadsafe
  2. perform poorly when multithreaded
  3. need state isolation

pytest-parallel is better for some use cases (like Selenium tests) that:

  1. can be threadsafe
  2. can use non-blocking IO for http requests to make it performant
  3. manage little or no state in the Python environment

Put simply, pytest-xdist does parallelism while pytest-parallel does parallelism and concurrency.

Requirements

  • Python3 version [3.6+]
  • Unix or Mac for --workers
  • Unix, Mac, or Windows for --tests-per-worker

Installation

pip install pytest-parallel

Options

  • workers (optional) - max workers (aka processes) to start. Can be a positive integer or auto which uses one worker per core. Defaults to 1.
  • tests-per-worker (optional) - max concurrent tests per worker. Can be a positive integer or auto which evenly divides tests among the workers up to 50 concurrent tests. Defaults to 1.

Examples

# runs 2 workers with 1 test per worker at a time
pytest --workers 2

# runs 4 workers (assuming a quad-core machine) with 1 test per worker
pytest --workers auto

# runs 1 worker with 4 tests at a time
pytest --tests-per-worker 4

# runs 1 worker with up to 50 tests at a time
pytest --tests-per-worker auto

# runs 2 workers with up to 50 tests per worker
pytest --workers 2 --tests-per-worker auto

Notice

Beginning with Python 3.8, forking behavior is forced on macOS at the expense of safety.

Changed in version 3.8: On macOS, the spawn start method is now the default. The fork start method should be considered unsafe as it can lead to crashes of the subprocess. See bpo-33725.

Source

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-parallel-0.1.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

pytest_parallel-0.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file pytest-parallel-0.1.0.tar.gz.

File metadata

  • Download URL: pytest-parallel-0.1.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for pytest-parallel-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4663a8fb805ac98b51e51de84d35ffd9717017fb71ed270440dc94b862466c20
MD5 a8b7a37bdde7d558e6fe982d6c690bca
BLAKE2b-256 588177b5f362c05f46722d2a49f94040d84dee85def82e1738164b8b4a073759

See more details on using hashes here.

File details

Details for the file pytest_parallel-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_parallel-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for pytest_parallel-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 10693161e350b59466ca331bad964073555cda114cc0499bd826deeceee512ed
MD5 992da922ba473ba768eeca618b86b172
BLAKE2b-256 f23b3fc19bb3c489acc53c48a711dd55c6f1bd502d65b287e3ba10c107409bac

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page