Add --no-loadscope-reorder and --loadscope-reorder options (#1217)

Based on #1098.

Closes #1098

---------

Co-authored-by: Toan Vuong <toan.vuong@hyperscience.com>
This commit is contained in:
darwintree
2025-06-30 21:59:40 +08:00
committed by GitHub
parent 532f07fb18
commit 9d7ba5b5fb
4 changed files with 58 additions and 5 deletions

View File

@@ -1254,6 +1254,24 @@ class TestLoadScope:
"test_b.py::test", result.outlines
) == {"gw0": 20}
def test_workqueue_ordered_by_input(self, pytester: pytest.Pytester) -> None:
test_file = """
import pytest
@pytest.mark.parametrize('i', range({}))
def test(i):
pass
"""
pytester.makepyfile(test_a=test_file.format(10), test_b=test_file.format(20))
result = pytester.runpytest(
"-n2", "--dist=loadscope", "--no-loadscope-reorder", "-v"
)
assert get_workers_and_test_count_by_prefix(
"test_a.py::test", result.outlines
) == {"gw0": 10}
assert get_workers_and_test_count_by_prefix(
"test_b.py::test", result.outlines
) == {"gw1": 20}
def test_module_single_start(self, pytester: pytest.Pytester) -> None:
"""Fix test suite never finishing in case all workers start with a single test (#277)."""
test_file1 = """