Skip to content

Commit 0c95b78

Browse files
committed
Integrate isoscope scheduling and distributed sccope isolation into xdist. Not tested yet.
1 parent 7c5a664 commit 0c95b78

9 files changed

+220
-148
lines changed

CHANGELOG.rst

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
pytest-xdist 3.ZZZ.ZZZ (2024-zz-zz)
2+
===============================
3+
4+
Features
5+
--------
6+
- `#1126 <https://github.com/pytest-dev/pytest-xdist/pull/1126>`_: New ``isoscope`` scheduler.
7+
18
pytest-xdist 3.6.1 (2024-04-28)
29
===============================
310

docs/distribution.rst

+13
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ The test distribution algorithm is configured with the ``--dist`` command-line o
4949

5050
.. _distribution modes:
5151

52+
* ``--dist isoscope``: Scope Isolation Scheduler. Tests are grouped by module for
53+
test functions and by class for test methods. Tests are executed one group at a
54+
time, distributed across available workers. This groupwise isolation guarantees
55+
that all tests in one group complete execution before running another group of
56+
tests. This can be useful when module-level or class-level fixtures of one group
57+
could create undesirable side-effects for tests in other test groups, while
58+
taking advantage of distributed execution of tests within each group. Grouping
59+
by class takes priority over grouping by module. NOTE: the use of this scheduler
60+
requires distributed coordination for setup and teardown such as provided by
61+
the ``iso_scheduling`` fixture or an alternate implementation of distributed
62+
coordination - see the ``iso_scheduling.coordinate_setup_teardown`` usage example
63+
in iso_scheduling_plugin.py.
64+
5265
* ``--dist load`` **(default)**: Sends pending tests to any worker that is
5366
available, without any guaranteed order. Scheduling can be fine-tuned with
5467
the `--maxschedchunk` option, see output of `pytest --help`.

pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ classifiers = [
3434
requires-python = ">=3.8"
3535
dependencies = [
3636
"execnet>=2.1",
37+
"filelock>=3.13.1",
3738
"pytest>=7.0.0",
3839
]
3940
dynamic = ["version"]
@@ -47,6 +48,7 @@ Tracker = "https://github.com/pytest-dev/pytest-xdist/issues"
4748

4849
[project.entry-points.pytest11]
4950
xdist = "xdist.plugin"
51+
"xdist.iso_scheduling_plugin" = "xdist.iso_scheduling_plugin"
5052
"xdist.looponfail" = "xdist.looponfail"
5153

5254
[project.optional-dependencies]

src/xdist/dsession.py

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from xdist.remote import Producer
1616
from xdist.remote import WorkerInfo
1717
from xdist.scheduler import EachScheduling
18+
from xdist.scheduler import IsoScopeScheduling
1819
from xdist.scheduler import LoadFileScheduling
1920
from xdist.scheduler import LoadGroupScheduling
2021
from xdist.scheduler import LoadScheduling
@@ -113,6 +114,8 @@ def pytest_xdist_make_scheduler(
113114
dist = config.getvalue("dist")
114115
if dist == "each":
115116
return EachScheduling(config, log)
117+
if dist == "isoscope":
118+
return IsoScopeScheduling(config, log)
116119
if dist == "load":
117120
return LoadScheduling(config, log)
118121
if dist == "loadscope":

0 commit comments

Comments
 (0)