Skip to content

Commit 80e56e0

Browse files
committed
Implemented acceptance test TestIsoScope.test_single_scope_all_workers_utilized
1 parent 2419551 commit 80e56e0

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

testing/acceptance_test.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,26 @@ def test_2():
12631263
assert a.items() == b.items()
12641264
assert c1 == c2
12651265

1266+
def test_single_scope_all_workers_utilized(self, pytester: pytest.Pytester) -> None:
1267+
"""
1268+
With single scope, there are no fence tests from another scope, so
1269+
this scheduler resorts to shutting down the workers in order to execute
1270+
the final tests in each worker. isoscope allocates at least two tests
1271+
per worker from the active scope, unless the scope has only one test.
1272+
"""
1273+
test_file = """
1274+
import pytest
1275+
@pytest.mark.parametrize('i', range(5))
1276+
def test(i):
1277+
pass
1278+
"""
1279+
pytester.makepyfile(test_a=test_file)
1280+
result = pytester.runpytest("-n2", "--dist=isoscope", "-v")
1281+
counts_by_worker = get_workers_and_test_count_by_prefix("test_a.py::test", result.outlines)
1282+
assert counts_by_worker["gw0"] in (2, 3)
1283+
assert counts_by_worker["gw1"] in (2, 3)
1284+
assert counts_by_worker["gw0"] + counts_by_worker["gw1"] == 5
1285+
12661286

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

0 commit comments

Comments
 (0)