Skip to content

Commit e2ebf44

Browse files
author
Release Manager
committed
Trac #33825: Use pytest-xdist to run pytest in parallel
(from https://trac.sagemath.org/ticket/33546#comment:13 - https://trac.sagemath.org/ticket/33546#comment:20) Use https://github.com/pytest-dev/pytest-xdist to run pytest in parallel. URL: https://trac.sagemath.org/33825 Reported by: mkoeppe Ticket author(s): Tobias Diez Reviewer(s): Dima Pasechnik, Matthias Koeppe
2 parents b400962 + a2e396b commit e2ebf44

File tree

7 files changed

+33
-3
lines changed

7 files changed

+33
-3
lines changed

build/pkgs/pytest/dependencies

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$(PYTHON) pluggy packaging attrs py pyparsing importlib_metadata | $(PYTHON_TOOLCHAIN)
1+
$(PYTHON) pluggy packaging attrs py pyparsing importlib_metadata tomli | $(PYTHON_TOOLCHAIN)
22

33
----------
44
All lines of this file are ignored except the first.

build/pkgs/pytest_xdist/SPKG.rst

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
pytest_xdist: pytest xdist plugin for distributed testing and loop-on-failing modes
2+
===================================================================================
3+
4+
Description
5+
-----------
6+
7+
pytest xdist plugin for distributed testing and loop-on-failing modes
8+
9+
License
10+
-------
11+
12+
MIT
13+
14+
Upstream Contact
15+
----------------
16+
17+
https://pypi.org/project/pytest-xdist/
18+

build/pkgs/pytest_xdist/dependencies

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
$(PYTHON) pytest | $(PYTHON_TOOLCHAIN)
2+
3+
----------
4+
All lines of this file are ignored except the first.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest-xdist
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest-xdist

build/pkgs/pytest_xdist/type

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
optional

src/doc/en/developer/tools.rst

+7-2
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,18 @@ package :mod:`sage.numerical.backends` and some modules in
252252

253253
*Installation:*
254254

255-
- ``./sage -i pytest``.
255+
- ``./sage -i pytest pytest_xdist``.
256256

257257
*Usage:*
258258

259259
- Tox, Sage doctester: At the end of ``./sage -t`` (or ``./sage --tox -e doctest``), Pytest is automatically invoked.
260260

261-
- Manual: Run ``./sage -pytest path/to/the/test_file.py`` or ``./sage -pytest`` to run all tests.
261+
- Manual: Run ``./sage -pytest path/to/the/test_file.py`` or ``./sage -pytest``
262+
to run all tests. The additional argument ``-n`` can be used to
263+
distribute tests across multiple CPUs to speed up test execution.
264+
For example, ``./sage -pytest -n 4`` will run 4 tests in parallel, while
265+
``./sage -pytest -n auto`` will spawn a number of workers processes equal
266+
to the number of available CPUs.
262267

263268
- VS Code: Install the `Python extension <https://marketplace.visualstudio.com/items?itemName=ms-python.python>`_ and follow the `offical VS Code documentation <https://code.visualstudio.com/docs/python/testing>`__.
264269

0 commit comments

Comments
 (0)