README.txt edited online with Bitbucket

This commit is contained in:
Anatoly Bubenkov
2015-03-01 14:45:15 +00:00
parent 94a7723ba8
commit 5da798f01f

View File

@@ -1,212 +1,215 @@
xdist: pytest distributed testing plugin .. image:: https://drone.io/bitbucket.org/pytest-dev/pytest-xdist/status.png
=============================================================== :target: https://drone.io/bitbucket.org/pytest-dev/pytest-xdist/latest
.. image:: https://pypip.in/v/pytest-xdist/badge.png
The `pytest-xdist`_ plugin extends py.test with some unique :target: https://pypi.python.org/pypi/pytest-xdist
test execution modes:
xdist: pytest distributed testing plugin
* test run parallelization_: if you have multiple CPUs or hosts you can use ============================
those for a combined test run. This allows to speed up
development or to use special resources of `remote machines`_. The `pytest-xdist`_ plugin extends py.test with some unique
test execution modes:
* ``--boxed``: (not available on Windows) run each test in a boxed_
subprocess to survive ``SEGFAULTS`` or otherwise dying processes * test run parallelization_: if you have multiple CPUs or hosts you can use
those for a combined test run. This allows to speed up
* ``--looponfail``: run your tests repeatedly in a subprocess. After each run development or to use special resources of `remote machines`_.
py.test waits until a file in your project changes and then re-runs
the previously failing tests. This is repeated until all tests pass * ``--boxed``: (not available on Windows) run each test in a boxed_
after which again a full run is performed. subprocess to survive ``SEGFAULTS`` or otherwise dying processes
* `Multi-Platform`_ coverage: you can specify different Python interpreters * ``--looponfail``: run your tests repeatedly in a subprocess. After each run
or different platforms and run tests in parallel on all of them. py.test waits until a file in your project changes and then re-runs
the previously failing tests. This is repeated until all tests pass
Before running tests remotely, ``py.test`` efficiently "rsyncs" your after which again a full run is performed.
program source code to the remote place. All test results
are reported back and displayed to your local terminal. * `Multi-Platform`_ coverage: you can specify different Python interpreters
You may specify different Python versions and interpreters. or different platforms and run tests in parallel on all of them.
Before running tests remotely, ``py.test`` efficiently "rsyncs" your
Installation program source code to the remote place. All test results
----------------------- are reported back and displayed to your local terminal.
You may specify different Python versions and interpreters.
Install the plugin with::
easy_install pytest-xdist Installation
-----------------------
# or
Install the plugin with::
pip install pytest-xdist
easy_install pytest-xdist
or use the package in develope/in-place mode with
a checkout of the `pytest-xdist repository`_ :: # or
python setup.py develop pip install pytest-xdist
Usage examples or use the package in develope/in-place mode with
--------------------- a checkout of the `pytest-xdist repository`_ ::
.. _parallelization: python setup.py develop
Speed up test runs by sending tests to multiple CPUs Usage examples
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ---------------------
To send tests to multiple CPUs, type:: .. _parallelization:
py.test -n NUM Speed up test runs by sending tests to multiple CPUs
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Especially for longer running tests or tests requiring
a lot of IO this can lead to considerable speed ups. To send tests to multiple CPUs, type::
py.test -n NUM
Running tests in a Python subprocess
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Especially for longer running tests or tests requiring
a lot of IO this can lead to considerable speed ups.
To instantiate a python2.5 sub process and send tests to it, you may type::
py.test -d --tx popen//python=python2.5 Running tests in a Python subprocess
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This will start a subprocess which is run with the "python2.5"
Python interpreter, found in your system binary lookup path. To instantiate a python2.5 sub process and send tests to it, you may type::
If you prefix the --tx option value like this:: py.test -d --tx popen//python=python2.5
--tx 3*popen//python=python2.5 This will start a subprocess which is run with the "python2.5"
Python interpreter, found in your system binary lookup path.
then three subprocesses would be created and tests
will be load-balanced across these three processes. If you prefix the --tx option value like this::
.. _boxed: --tx 3*popen//python=python2.5
Running tests in a boxed subprocess then three subprocesses would be created and tests
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ will be load-balanced across these three processes.
If you have tests involving C or C++ libraries you might have to deal .. _boxed:
with tests crashing the process. For this case you may use the boxing
options:: Running tests in a boxed subprocess
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
py.test --boxed
If you have tests involving C or C++ libraries you might have to deal
which will run each test in a subprocess and will report if a test with tests crashing the process. For this case you may use the boxing
crashed the process. You can also combine this option with options::
running multiple processes to speed up the test run and use your CPU cores::
py.test --boxed
py.test -n3 --boxed
which will run each test in a subprocess and will report if a test
this would run 3 testing subprocesses in parallel which each crashed the process. You can also combine this option with
create new boxed subprocesses for each test. running multiple processes to speed up the test run and use your CPU cores::
py.test -n3 --boxed
.. _`remote machines`:
this would run 3 testing subprocesses in parallel which each
Sending tests to remote SSH accounts create new boxed subprocesses for each test.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Suppose you have a package ``mypkg`` which contains some .. _`remote machines`:
tests that you can successfully run locally. And you
have a ssh-reachable machine ``myhost``. Then Sending tests to remote SSH accounts
you can ad-hoc distribute your tests by typing:: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
py.test -d --tx ssh=myhostpopen --rsyncdir mypkg mypkg Suppose you have a package ``mypkg`` which contains some
tests that you can successfully run locally. And you
This will synchronize your ``mypkg`` package directory have a ssh-reachable machine ``myhost``. Then
to an remote ssh account and then locally collect tests you can ad-hoc distribute your tests by typing::
and send them to remote places for execution.
py.test -d --tx ssh=myhostpopen --rsyncdir mypkg mypkg
You can specify multiple ``--rsyncdir`` directories
to be sent to the remote side. This will synchronize your ``mypkg`` package directory
to an remote ssh account and then locally collect tests
**NOTE:** For py.test to collect and send tests correctly and send them to remote places for execution.
you not only need to make sure all code and tests
directories are rsynced, but that any test (sub) directory You can specify multiple ``--rsyncdir`` directories
also has an ``__init__.py`` file because internally to be sent to the remote side.
py.test references tests as a fully qualified python
module path. **You will otherwise get strange errors** **NOTE:** For py.test to collect and send tests correctly
during setup of the remote side. you not only need to make sure all code and tests
directories are rsynced, but that any test (sub) directory
You can specify multiple ``--rsyncignore`` glob-patterns also has an ``__init__.py`` file because internally
to be ignored when file are sent to the remote side. py.test references tests as a fully qualified python
There are also internal ignores: .*, *.pyc, *.pyo, *~ module path. **You will otherwise get strange errors**
Those you cannot override using rsyncignore command-line or during setup of the remote side.
ini-file option(s).
You can specify multiple ``--rsyncignore`` glob-patterns
to be ignored when file are sent to the remote side.
Sending tests to remote Socket Servers There are also internal ignores: .*, *.pyc, *.pyo, *~
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Those you cannot override using rsyncignore command-line or
ini-file option(s).
Download the single-module `socketserver.py`_ Python program
and run it like this::
Sending tests to remote Socket Servers
python socketserver.py +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
It will tell you that it starts listening on the default Download the single-module `socketserver.py`_ Python program
port. You can now on your home machine specify this and run it like this::
new socket host with something like this::
python socketserver.py
py.test -d --tx socket=192.168.1.102:8888 --rsyncdir mypkg mypkg
It will tell you that it starts listening on the default
port. You can now on your home machine specify this
.. _`atonce`: new socket host with something like this::
.. _`Multi-Platform`:
py.test -d --tx socket=192.168.1.102:8888 --rsyncdir mypkg mypkg
Running tests on many platforms at once
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .. _`atonce`:
.. _`Multi-Platform`:
The basic command to run tests on multiple platforms is::
py.test --dist=each --tx=spec1 --tx=spec2 Running tests on many platforms at once
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
If you specify a windows host, an OSX host and a Linux
environment this command will send each tests to all The basic command to run tests on multiple platforms is::
platforms - and report back failures from all platforms
at once. The specifications strings use the `xspec syntax`_. py.test --dist=each --tx=spec1 --tx=spec2
.. _`xspec syntax`: http://codespeak.net/execnet/trunk/basics.html#xspec If you specify a windows host, an OSX host and a Linux
environment this command will send each tests to all
.. _`socketserver.py`: http://bitbucket.org/hpk42/execnet/raw/2af991418160/execnet/script/socketserver.py platforms - and report back failures from all platforms
at once. The specifications strings use the `xspec syntax`_.
.. _`execnet`: http://codespeak.net/execnet
.. _`xspec syntax`: http://codespeak.net/execnet/trunk/basics.html#xspec
Specifying test exec environments in an ini file
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .. _`socketserver.py`: http://bitbucket.org/hpk42/execnet/raw/2af991418160/execnet/script/socketserver.py
pytest (since version 2.0) supports ini-style cofiguration. .. _`execnet`: http://codespeak.net/execnet
You can for example make running with three subprocesses
your default like this:: Specifying test exec environments in an ini file
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[pytest]
addopts = -n3 pytest (since version 2.0) supports ini-style cofiguration.
You can for example make running with three subprocesses
You can also add default environments like this:: your default like this::
[pytest] [pytest]
addopts = --tx ssh=myhost//python=python2.5 --tx ssh=myhost//python=python2.6 addopts = -n3
and then just type:: You can also add default environments like this::
py.test --dist=each [pytest]
addopts = --tx ssh=myhost//python=python2.5 --tx ssh=myhost//python=python2.6
to run tests in each of the environments.
and then just type::
Specifying "rsync" dirs in an ini-file
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ py.test --dist=each
In a ``tox.ini`` or ``setup.cfg`` file in your root project directory to run tests in each of the environments.
you may specify directories to include or to exclude in synchronisation::
Specifying "rsync" dirs in an ini-file
[pytest] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
rsyncdirs = . mypkg helperpkg
rsyncignore = .hg In a ``tox.ini`` or ``setup.cfg`` file in your root project directory
you may specify directories to include or to exclude in synchronisation::
These directory specifications are relative to the directory
where the configuration file was found. [pytest]
rsyncdirs = . mypkg helperpkg
.. _`pytest-xdist`: http://pypi.python.org/pypi/pytest-xdist rsyncignore = .hg
.. _`pytest-xdist repository`: http://bitbucket.org/pytest-dev/pytest-xdist
.. _`pytest`: http://pytest.org These directory specifications are relative to the directory
where the configuration file was found.
Issue and Bug Tracker
------------------------ .. _`pytest-xdist`: http://pypi.python.org/pypi/pytest-xdist
.. _`pytest-xdist repository`: http://bitbucket.org/pytest-dev/pytest-xdist
Please use the pytest issue tracker for bugs in this plugin, see https://bitbucket.org/hpk42/pytest/issues . .. _`pytest`: http://pytest.org
Issue and Bug Tracker
------------------------
Please use the pytest issue tracker for bugs in this plugin, see https://bitbucket.org/hpk42/pytest/issues .