skip to navigation
skip to content

pytest-xprocess 0.9.1

pytest plugin to manage external processes across test runs

.. image::
.. image::

experimental py.test plugin for managing processes across test runs


install via::

pip install pytest-xprocess

This will provide a ``xprocess`` fixture which helps
you to ensure that one ore more longer-running processes
are present for your tests. You can use it to start and
pre-configure test-specific databases (Postgres, Couchdb, ...).

Additionally there are two new command line options::

--xkill # kills all external processes
--xshow # shows currently running processes and log files

``xprocess`` fixture usage

You typically define a project-specific fixture which
uses the ``xprocess`` fixture internally::

# content of

import pytest

def myserver(xprocess):
def preparefunc(cwd):
return ("PATTERN", [subprocess args])

logfile = xprocess.ensure("myserver", preparefunc)
conn = # create a connection or url/port info to the server
return conn

The ``xprocess.ensure`` function takes a name for the external process
because you can have multiple external processes.

The ``preparefunc`` is a function which gets the current working directory and
returns a ``(PATTERN, args, env)`` tuple. If the server has not yet been

- the returned ``args`` are used to perform a subprocess invocation with
environment ``env`` (a mapping) and redirect its stdout to a new logfile

- the ``PATTERN`` is waited for in the logfile before returning.
It should thus match a state of your server where it is ready to
answer queries.

- the logfile is returned pointing to the line right after the match

else, if the server is already running simply the logfile is returned.

To inherit the main test process environment, return ``None`` for ``env``, or
omit it and return just ``(PATTERN, args)`` from the ``preparefunc``.

Note that the plugin needs to persist the process ID and logfile
information. It does this in a sub directory of the directory
which contains a ``pytest.ini`` or ```` file.


The repository of this plugin is at

For more info on py.test see  
File Type Py Version Uploaded on Size
pytest-xprocess-0.9.1.tar.gz (md5) Source 2015-07-15 7KB
pytest_xprocess-0.9.1-py2.py3-none-any.whl (md5) Python Wheel 2.7 2015-07-15 7KB