Skip to content

Commit 2e7f715

Browse files
committed
Enhance loadscope options: add --loadscope-reorder to align the param behaviour with argparse
1 parent bd056b2 commit 2e7f715

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

changelog/1083.improvement.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
Add ``--no-loadscope-reorder`` option to disable automatic reordering of tests in loadscope for tests where relative ordering matters. This only applies when using ``loadscope``.
1+
Add ``--no-loadscope-reorder`` and ``--loadscope-reorder`` option to control whether to automatically reorder tests in loadscope for tests where relative ordering matters. This only applies when using ``loadscope``.
22

33
For example, [test_file_1, test_file_2, ..., test_file_n] are given as input test files, if ``--no-loadscope-reorder`` is used, for either worker, the ``test_file_a`` will be executed before ``test_file_b`` only if ``a < b``.
4+
5+
The default behavior is to reorder the tests to maximize the number of tests that can be executed in parallel.

src/xdist/plugin.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,23 @@ def pytest_addoption(parser: pytest.Parser) -> None:
127127
"(default) no: Run tests inprocess, don't distribute."
128128
),
129129
)
130+
group.addoption(
131+
"--loadscope-reorder",
132+
dest="loadscopereorder",
133+
action="store_true",
134+
default=True,
135+
help=(
136+
"Pytest-xdist will default reorder tests by number of tests per scope "
137+
"when used in conjunction with loadscope.\n"
138+
"This option will enable loadscope reorder which will improve the "
139+
"parallelism of the test suite.\n"
140+
"However, the partial order of tests might not be retained.\n"
141+
),
142+
)
130143
group.addoption(
131144
"--no-loadscope-reorder",
132145
dest="loadscopereorder",
133146
action="store_false",
134-
default=True,
135147
help=(
136148
"Pytest-xdist will default reorder tests by number of tests per scope "
137149
"when used in conjunction with loadscope.\n"

0 commit comments

Comments
 (0)