@@ -1285,6 +1285,29 @@ def test(i):
1285
1285
assert counts_by_worker ["gw1" ] in (2 , 3 )
1286
1286
assert counts_by_worker ["gw0" ] + counts_by_worker ["gw1" ] == 5
1287
1287
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
+
1288
1311
1289
1312
class TestLoadScope :
1290
1313
def test_by_module (self , pytester : pytest .Pytester ) -> None :
0 commit comments