File tree Expand file tree Collapse file tree 2 files changed +32
-6
lines changed
Expand file tree Collapse file tree 2 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -238,12 +238,6 @@ def pytest_collection_modifyitems(
238238
239239 groups = _partition_list (items , cdist_config .total_groups )
240240
241- if cdist_config .justify_items_strategy != "none" :
242- groups = _justify_items (groups , strategy = cdist_config .justify_items_strategy )
243-
244- if os .getenv ("PYTEST_XDIST_WORKER" ):
245- groups = _justify_xdist_groups (groups )
246-
247241 if cdist_config .group_steal is not None :
248242 target_group , amount_to_steal = cdist_config .group_steal
249243 groups = _distribute_with_bias (
@@ -252,6 +246,12 @@ def pytest_collection_modifyitems(
252246 bias = amount_to_steal ,
253247 )
254248
249+ if cdist_config .justify_items_strategy != "none" :
250+ groups = _justify_items (groups , strategy = cdist_config .justify_items_strategy )
251+
252+ if os .getenv ("PYTEST_XDIST_WORKER" ):
253+ groups = _justify_xdist_groups (groups )
254+
255255 new_items = groups .pop (cdist_config .current_group )
256256 deselect = [item for group in groups for item in group ]
257257
Original file line number Diff line number Diff line change @@ -209,6 +209,32 @@ def test_four():
209209 result .assert_outcomes (passed = 3 , deselected = 1 )
210210
211211
212+ def test_steal_with_justify (pytester : pytest .Pytester ) -> None :
213+ pytester .makepyfile ("""
214+ class TestFoo:
215+ def test_one(self):
216+ assert True
217+
218+ def test_two(self):
219+ assert True
220+ """ )
221+
222+ # Stealing should never break the scope
223+ result = pytester .runpytest (
224+ "--cdist-group=1/2" ,
225+ "--cdist-justify-items=scope" ,
226+ "--cdist-group-steal=2:60" ,
227+ )
228+ result .assert_outcomes (passed = 2 , deselected = 0 )
229+
230+ result = pytester .runpytest (
231+ "--cdist-group=2/2" ,
232+ "--cdist-justify-items=scope" ,
233+ "--cdist-group-steal=2:60" ,
234+ )
235+ result .assert_outcomes (passed = 0 , deselected = 2 )
236+
237+
212238def test_raises_for_invalid_randomly_cfg (pytester : pytest .Pytester ) -> None :
213239 pytester .makeini ("" )
214240
You can’t perform that action at this time.
0 commit comments