METADATA 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. Metadata-Version: 2.1
  2. Name: pytest-xdist
  3. Version: 1.23.0
  4. Summary: pytest xdist plugin for distributed testing and loop-on-failing modes
  5. Home-page: https://github.com/pytest-dev/pytest-xdist
  6. Author: holger krekel and contributors
  7. Author-email: pytest-dev@python.org,holger@merlinux.eu
  8. License: MIT
  9. Platform: linux
  10. Platform: osx
  11. Platform: win32
  12. Classifier: Development Status :: 5 - Production/Stable
  13. Classifier: Framework :: Pytest
  14. Classifier: Intended Audience :: Developers
  15. Classifier: License :: OSI Approved :: MIT License
  16. Classifier: Operating System :: POSIX
  17. Classifier: Operating System :: Microsoft :: Windows
  18. Classifier: Operating System :: MacOS :: MacOS X
  19. Classifier: Topic :: Software Development :: Testing
  20. Classifier: Topic :: Software Development :: Quality Assurance
  21. Classifier: Topic :: Utilities
  22. Classifier: Programming Language :: Python
  23. Classifier: Programming Language :: Python :: 2
  24. Classifier: Programming Language :: Python :: 2.7
  25. Classifier: Programming Language :: Python :: 3
  26. Classifier: Programming Language :: Python :: 3.4
  27. Classifier: Programming Language :: Python :: 3.5
  28. Classifier: Programming Language :: Python :: 3.6
  29. Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
  30. Requires-Dist: execnet (>=1.1)
  31. Requires-Dist: pytest (>=3.0.0)
  32. Requires-Dist: pytest-forked
  33. Requires-Dist: six
  34. .. image:: http://img.shields.io/pypi/v/pytest-xdist.svg
  35. :alt: PyPI version
  36. :target: https://pypi.python.org/pypi/pytest-xdist
  37. .. image:: https://img.shields.io/conda/vn/conda-forge/pytest-xdist.svg
  38. :target: https://anaconda.org/conda-forge/pytest-xdist
  39. .. image:: https://img.shields.io/pypi/pyversions/pytest-xdist.svg
  40. :alt: Python versions
  41. :target: https://pypi.python.org/pypi/pytest-xdist
  42. .. image:: https://travis-ci.org/pytest-dev/pytest-xdist.svg?branch=master
  43. :alt: Travis CI build status
  44. :target: https://travis-ci.org/pytest-dev/pytest-xdist
  45. .. image:: https://ci.appveyor.com/api/projects/status/56eq1a1avd4sdd7e/branch/master?svg=true
  46. :alt: AppVeyor build status
  47. :target: https://ci.appveyor.com/project/pytestbot/pytest-xdist
  48. .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
  49. :target: https://github.com/ambv/black
  50. xdist: pytest distributed testing plugin
  51. ========================================
  52. The `pytest-xdist`_ plugin extends pytest with some unique
  53. test execution modes:
  54. * test run parallelization_: if you have multiple CPUs or hosts you can use
  55. those for a combined test run. This allows to speed up
  56. development or to use special resources of `remote machines`_.
  57. * ``--looponfail``: run your tests repeatedly in a subprocess. After each run
  58. pytest waits until a file in your project changes and then re-runs
  59. the previously failing tests. This is repeated until all tests pass
  60. after which again a full run is performed.
  61. * `Multi-Platform`_ coverage: you can specify different Python interpreters
  62. or different platforms and run tests in parallel on all of them.
  63. Before running tests remotely, ``pytest`` efficiently "rsyncs" your
  64. program source code to the remote place. All test results
  65. are reported back and displayed to your local terminal.
  66. You may specify different Python versions and interpreters.
  67. If you would like to know how pytest-xdist works under the covers, checkout
  68. `OVERVIEW <https://github.com/pytest-dev/pytest-xdist/blob/master/OVERVIEW.md>`_.
  69. Installation
  70. ------------
  71. Install the plugin with::
  72. pip install pytest-xdist
  73. or use the package in develop/in-place mode with
  74. a checkout of the `pytest-xdist repository`_ ::
  75. pip install --editable .
  76. .. _parallelization:
  77. Speed up test runs by sending tests to multiple CPUs
  78. ----------------------------------------------------
  79. To send tests to multiple CPUs, type::
  80. pytest -n NUM
  81. Especially for longer running tests or tests requiring
  82. a lot of I/O this can lead to considerable speed ups. This option can
  83. also be set to ``auto`` for automatic detection of the number of CPUs.
  84. If a test crashes the interpreter, pytest-xdist will automatically restart
  85. that worker and report the failure as usual. You can use the
  86. ``--max-worker-restart`` option to limit the number of workers that can
  87. be restarted, or disable restarting altogether using ``--max-worker-restart=0``.
  88. By default, the ``-n`` option will send pending tests to any worker that is available, without
  89. any guaranteed order, but you can control this with these options:
  90. * ``--dist=loadscope``: tests will be grouped by **module** for *test functions* and
  91. by **class** for *test methods*, then each group will be sent to an available worker,
  92. guaranteeing that all tests in a group run in the same process. This can be useful if you have
  93. expensive module-level or class-level fixtures. Currently the groupings can't be customized,
  94. with grouping by class takes priority over grouping by module.
  95. This feature was added in version ``1.19``.
  96. * ``--dist=loadfile``: tests will be grouped by file name, and then will be sent to an available
  97. worker, guaranteeing that all tests in a group run in the same worker. This feature was added
  98. in version ``1.21``.
  99. Running tests in a Python subprocess
  100. ------------------------------------
  101. To instantiate a python3.5 subprocess and send tests to it, you may type::
  102. pytest -d --tx popen//python=python3.5
  103. This will start a subprocess which is run with the ``python3.5``
  104. Python interpreter, found in your system binary lookup path.
  105. If you prefix the --tx option value like this::
  106. --tx 3*popen//python=python3.5
  107. then three subprocesses would be created and tests
  108. will be load-balanced across these three processes.
  109. .. _boxed:
  110. Running tests in a boxed subprocess
  111. -----------------------------------
  112. This functionality has been moved to the
  113. `pytest-forked <https://github.com/pytest-dev/pytest-forked>`_ plugin, but the ``--boxed`` option
  114. is still kept for backward compatibility.
  115. .. _`remote machines`:
  116. Sending tests to remote SSH accounts
  117. ------------------------------------
  118. Suppose you have a package ``mypkg`` which contains some
  119. tests that you can successfully run locally. And you
  120. have a ssh-reachable machine ``myhost``. Then
  121. you can ad-hoc distribute your tests by typing::
  122. pytest -d --tx ssh=myhostpopen --rsyncdir mypkg mypkg
  123. This will synchronize your :code:`mypkg` package directory
  124. to a remote ssh account and then locally collect tests
  125. and send them to remote places for execution.
  126. You can specify multiple :code:`--rsyncdir` directories
  127. to be sent to the remote side.
  128. .. note::
  129. For pytest to collect and send tests correctly
  130. you not only need to make sure all code and tests
  131. directories are rsynced, but that any test (sub) directory
  132. also has an :code:`__init__.py` file because internally
  133. pytest references tests as a fully qualified python
  134. module path. **You will otherwise get strange errors**
  135. during setup of the remote side.
  136. You can specify multiple :code:`--rsyncignore` glob patterns
  137. to be ignored when file are sent to the remote side.
  138. There are also internal ignores: :code:`.*, *.pyc, *.pyo, *~`
  139. Those you cannot override using rsyncignore command-line or
  140. ini-file option(s).
  141. Sending tests to remote Socket Servers
  142. --------------------------------------
  143. Download the single-module `socketserver.py`_ Python program
  144. and run it like this::
  145. python socketserver.py
  146. It will tell you that it starts listening on the default
  147. port. You can now on your home machine specify this
  148. new socket host with something like this::
  149. pytest -d --tx socket=192.168.1.102:8888 --rsyncdir mypkg mypkg
  150. .. _`atonce`:
  151. .. _`Multi-Platform`:
  152. Running tests on many platforms at once
  153. ---------------------------------------
  154. The basic command to run tests on multiple platforms is::
  155. pytest --dist=each --tx=spec1 --tx=spec2
  156. If you specify a windows host, an OSX host and a Linux
  157. environment this command will send each tests to all
  158. platforms - and report back failures from all platforms
  159. at once. The specifications strings use the `xspec syntax`_.
  160. .. _`xspec syntax`: http://codespeak.net/execnet/basics.html#xspec
  161. .. _`socketserver.py`: http://bitbucket.org/hpk42/execnet/raw/2af991418160/execnet/script/socketserver.py
  162. .. _`execnet`: http://codespeak.net/execnet
  163. Identifying the worker process during a test
  164. --------------------------------------------
  165. *New in version 1.15.*
  166. If you need to determine the identity of a worker process in
  167. a test or fixture, you may use the ``worker_id`` fixture to do so:
  168. .. code-block:: python
  169. @pytest.fixture()
  170. def user_account(worker_id):
  171. """ use a different account in each xdist worker """
  172. return "account_%s" % worker_id
  173. When ``xdist`` is disabled (running with ``-n0`` for example), then
  174. ``worker_id`` will return ``"master"``.
  175. Additionally, worker processes have the following environment variables
  176. defined:
  177. * ``PYTEST_XDIST_WORKER``: the name of the worker, e.g., ``"gw2"``.
  178. * ``PYTEST_XDIST_WORKER_COUNT``: the total number of workers in this session,
  179. e.g., ``"4"`` when ``-n 4`` is given in the command-line.
  180. The information about the worker_id in a test is stored in the ``TestReport`` as
  181. well, under the ``worker_id`` attribute.
  182. Specifying test exec environments in an ini file
  183. ------------------------------------------------
  184. You can use pytest's ini file configuration to avoid typing common options.
  185. You can for example make running with three subprocesses your default like this:
  186. .. code-block:: ini
  187. [pytest]
  188. addopts = -n3
  189. You can also add default environments like this:
  190. .. code-block:: ini
  191. [pytest]
  192. addopts = --tx ssh=myhost//python=python3.5 --tx ssh=myhost//python=python3.6
  193. and then just type::
  194. pytest --dist=each
  195. to run tests in each of the environments.
  196. Specifying "rsync" dirs in an ini-file
  197. --------------------------------------
  198. In a ``tox.ini`` or ``setup.cfg`` file in your root project directory
  199. you may specify directories to include or to exclude in synchronisation:
  200. .. code-block:: ini
  201. [pytest]
  202. rsyncdirs = . mypkg helperpkg
  203. rsyncignore = .hg
  204. These directory specifications are relative to the directory
  205. where the configuration file was found.
  206. .. _`pytest-xdist`: http://pypi.python.org/pypi/pytest-xdist
  207. .. _`pytest-xdist repository`: https://github.com/pytest-dev/pytest-xdist
  208. .. _`pytest`: http://pytest.org