pytest plugin to manage external processes across test runs
Experimental py.test plugin for managing processes across test runs.
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 # terminates all external processes --xshow # shows currently running processes and log files
You typically define a project-specific fixture which uses the xprocess fixture internally:
# content of conftest.py import pytest @pytest.fixture 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 started:
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 setup.py file.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|File Name & Checksum SHA256 Checksum Help||Version||File Type||Upload Date|
|pytest_xprocess-0.11-py2.py3-none-any.whl (7.0 kB) Copy SHA256 Checksum SHA256||3.6||Wheel||May 18, 2017|
|pytest-xprocess-0.11.tar.gz (10.6 kB) Copy SHA256 Checksum SHA256||–||Source||May 18, 2017|