Skip to content

Commit 3de8be1

Browse files
committed
Implemented acceptance test TestIsoScope.test_single_scope_subset_of_workers_utilized.
1 parent fc6e6ce commit 3de8be1

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

testing/acceptance_test.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,29 @@ def test(i):
12851285
assert counts_by_worker["gw1"] in (2, 3)
12861286
assert counts_by_worker["gw0"] + counts_by_worker["gw1"] == 5
12871287

1288+
@pytest.mark.parametrize('num_tests', [1, 2, 3])
1289+
def test_single_scope_subset_of_workers_utilized(self,
1290+
num_tests: int,
1291+
pytester: pytest.Pytester) -> None:
1292+
"""
1293+
With single scope, there are no fence tests from another scope, so
1294+
this scheduler resorts to shutting down the workers in order to execute
1295+
the final tests in each worker. isoscope allocates at least two tests
1296+
per worker from the active scope, unless the scope has only one test.
1297+
"""
1298+
test_file = f"""
1299+
import pytest
1300+
@pytest.mark.parametrize('i', range({num_tests}))
1301+
def test(i):
1302+
pass
1303+
"""
1304+
pytester.makepyfile(test_a=test_file)
1305+
result = pytester.runpytest("-n2", "--dist=isoscope", "-v")
1306+
counts_by_worker = get_workers_and_test_count_by_prefix("test_a.py::test", result.outlines)
1307+
assert counts_by_worker["gw0"] in (0, num_tests)
1308+
assert counts_by_worker["gw1"] in (0, num_tests)
1309+
assert counts_by_worker["gw0"] + counts_by_worker["gw1"] == num_tests
1310+
12881311

12891312
class TestLoadScope:
12901313
def test_by_module(self, pytester: pytest.Pytester) -> None:

0 commit comments

Comments
 (0)