@@ -1198,6 +1198,72 @@ def pytest_collection_modifyitems():
11981198 result .stdout .fnmatch_lines (["*RuntimeError: Some runtime error*" ])
11991199
12001200
1201+ class TestIsoScope :
1202+ def test_by_module (self , pytester : pytest .Pytester ) -> None :
1203+ test_file = """
1204+ import pytest
1205+ @pytest.mark.parametrize('i', range(10))
1206+ def test(i):
1207+ pass
1208+ """
1209+ pytester .makepyfile (test_a = test_file , test_b = test_file )
1210+ result = pytester .runpytest ("-n2" , "--dist=isoscope" , "-v" )
1211+ assert get_workers_and_test_count_by_prefix (
1212+ "test_a.py::test" , result .outlines
1213+ ) in ({"gw0" : 10 }, {"gw1" : 10 })
1214+ assert get_workers_and_test_count_by_prefix (
1215+ "test_b.py::test" , result .outlines
1216+ ) in ({"gw0" : 10 }, {"gw1" : 10 })
1217+
1218+ def test_by_class (self , pytester : pytest .Pytester ) -> None :
1219+ pytester .makepyfile (
1220+ test_a = """
1221+ import pytest
1222+ class TestA:
1223+ @pytest.mark.parametrize('i', range(10))
1224+ def test(self, i):
1225+ pass
1226+
1227+ class TestB:
1228+ @pytest.mark.parametrize('i', range(10))
1229+ def test(self, i):
1230+ pass
1231+ """
1232+ )
1233+ result = pytester .runpytest ("-n2" , "--dist=isoscope" , "-v" )
1234+ assert get_workers_and_test_count_by_prefix (
1235+ "test_a.py::TestA" , result .outlines
1236+ ) in ({"gw0" : 10 }, {"gw1" : 10 })
1237+ assert get_workers_and_test_count_by_prefix (
1238+ "test_a.py::TestB" , result .outlines
1239+ ) in ({"gw0" : 10 }, {"gw1" : 10 })
1240+
1241+ def test_module_single_start (self , pytester : pytest .Pytester ) -> None :
1242+ """Ensure test suite finishing in case all workers start with a single test (#277)."""
1243+ test_file1 = """
1244+ import pytest
1245+ def test():
1246+ pass
1247+ """
1248+ test_file2 = """
1249+ import pytest
1250+ def test_1():
1251+ pass
1252+ def test_2():
1253+ pass
1254+ """
1255+ pytester .makepyfile (test_a = test_file1 , test_b = test_file1 , test_c = test_file2 )
1256+ result = pytester .runpytest ("-n2" , "--dist=isoscope" , "-v" )
1257+ a = get_workers_and_test_count_by_prefix ("test_a.py::test" , result .outlines )
1258+ b = get_workers_and_test_count_by_prefix ("test_b.py::test" , result .outlines )
1259+ c1 = get_workers_and_test_count_by_prefix ("test_c.py::test_1" , result .outlines )
1260+ c2 = get_workers_and_test_count_by_prefix ("test_c.py::test_2" , result .outlines )
1261+ assert a in ({"gw0" : 1 }, {"gw1" : 1 })
1262+ assert b in ({"gw0" : 1 }, {"gw1" : 1 })
1263+ assert a .items () != b .items ()
1264+ assert c1 == c2
1265+
1266+
12011267class TestLoadScope :
12021268 def test_by_module (self , pytester : pytest .Pytester ) -> None :
12031269 test_file = """
0 commit comments