skillfed

pytest-xprocess

A pytest plugin for managing processes across test runs.

pytest-xprocess v1.0.2 307.6K downloads/30d#7,774 on PyPI108
Permissive license MIT Active released

What it is and what it does

pytest-xprocess is a pytest plugin that handles the lifecycle of external processes during test execution. Rather than starting and stopping a service (like a database, cache, or API server) for each test, it manages long-lived processes that can be reused across multiple tests, reducing test overhead and improving speed.

The plugin works by maintaining process state across test runs and providing fixtures to interact with these processes. It depends on pytest for the test framework integration and psutil for cross-platform process management. It supports Python 3.8 through 3.11 and is classified as Beta stability, indicating it is mature but may still have minor API changes.

Use it for:

  • Start a database server once and reuse it across all tests instead of spinning up a new instance per test.
  • Manage a mock API or HTTP service that multiple test cases need to communicate with.
  • Control background worker processes or message queues during integration testing.
  • Reduce test suite runtime by avoiding repeated startup costs of external services.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

pytest-xprocess manages external processes (like servers or services) across pytest test runs, allowing tests to start, reuse, and control long-lived processes without restarting them for each test.

Yes, if your test suite relies on external processes. The plugin is actively maintained, has low install friction, carries no security vulnerabilities, and uses a permissive MIT license. It is well-suited for integration tests that need to manage services across multiple test runs.

Install

pytest-xprocess on PyPI

pip

pip install pytest-xprocess

uv

uv add pytest-xprocess

poetry

poetry add pytest-xprocess

Installing pytest-xprocess

Before you install

Low friction install with only pytest and psutil as runtime dependencies. The package is actively maintained with a recent commit history and has been stable since its early releases.

License in practice

MIT license is permissive, allowing use in commercial and open-source projects with minimal restrictions.

Quickstart

pip install pytest-xprocess

import pytest
from pytest_xprocess import XProcess

def test_with_process(xprocess):
    # xprocess manages the external process lifecycle
    xprocess.ensure("my_service", lambda: ...)

Verify before relying

  • Whether the plugin supports process cleanup and signal handling across different operating systems.
  • Performance characteristics when managing many concurrent external processes.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 2 — pytest, psutil
Maintenance actively maintained — 817 days since the last release
Last repo commit
First released
Downloads 307,612/month — #7,774 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pytest_xprocess-1.0.2-py3-none-any.whl

Development Status :: 4 - BetaFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: LibrariesTopic :: Software Development :: TestingTopic :: Utilities

Tags

pytest external process managementmanage server processes in testspytest long-running servicesreuse processes across test runspytest process fixturescontrol external processes pytest
pytest-pluginprocess-managementintegration-testing

More Libraries packages