pytest-parallel

0.1.1 · abandoned · verified Sun Apr 12

pytest-parallel is a pytest plugin that enables parallel and concurrent testing by utilizing both multiprocessing (workers) and multithreading (tests per worker). It is designed for specific use cases, such as Selenium tests, where tests can be thread-safe, benefit from non-blocking I/O, and manage minimal state in the Python environment. It is not intended as a direct replacement for pytest-xdist, which focuses solely on process-based parallelism for general test distribution. The current version is 0.1.1. The project appears to be unmaintained.

Warnings

Install

Quickstart

Create a test file (e.g., `test_example.py`) and then execute pytest from your terminal, specifying the number of workers (processes) and tests per worker (concurrent threads). This example demonstrates how to set up simple tests for parallel and concurrent execution.

import time
import pytest

# test_example.py

def test_fast_operation_1():
    time.sleep(0.01)
    assert True

def test_fast_operation_2():
    time.sleep(0.01)
    assert True

def test_fast_operation_3():
    time.sleep(0.01)
    assert True

def test_slow_operation_1():
    time.sleep(0.1)
    assert True

def test_slow_operation_2():
    time.sleep(0.1)
    assert True

# Run with: pytest --workers 2 --tests-per-worker 2
# This will execute tests using 2 processes, with each process running up to 2 tests concurrently.

view raw JSON →