aboutsummaryrefslogtreecommitdiffstats
path: root/library/python/pytest
diff options
context:
space:
mode:
authorsomov <somov@yandex-team.com>2023-05-23 14:26:53 +0300
committersomov <somov@yandex-team.com>2023-05-23 14:26:53 +0300
commit61a58106f42a87d3d324e03e77642faf0a488071 (patch)
treec83303c0ad3c3f1ec80cde781d2fb8d1ebd8b11f /library/python/pytest
parentf3c6234b782432148c8f8afb7ba9ba28d402148e (diff)
downloadydb-61a58106f42a87d3d324e03e77642faf0a488071.tar.gz
Preserve tests order when splitting by chunks
Diffstat (limited to 'library/python/pytest')
-rw-r--r--library/python/pytest/plugins/ya.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/library/python/pytest/plugins/ya.py b/library/python/pytest/plugins/ya.py
index 1129609c7c..a9ad446d67 100644
--- a/library/python/pytest/plugins/ya.py
+++ b/library/python/pytest/plugins/ya.py
@@ -429,6 +429,8 @@ def pytest_deselected(items):
@pytest.hookimpl(trylast=True)
def pytest_collection_modifyitems(items, config):
+ item_ids_order = [item.nodeid for item in items]
+
def filter_items(filters):
filtered_items = []
deselected_items = []
@@ -490,10 +492,23 @@ def pytest_collection_modifyitems(items, config):
items_by_classes[class_name].append(item)
else:
res.append([item])
+
chunk_items = test_splitter.get_splitted_tests(res, modulo, modulo_index, partition_mode, is_sorted=True)
+
+ item_by_id = {}
+ for item_group in chunk_items:
+ for item in item_group:
+ item_by_id[item.nodeid] = item
+
+ # Should preserve the original order of the items.
+ # It is crucial for the correct application of test fixtures.
+ # See DEVTOOLSSUPPORT-28496 for details.
items[:] = []
- for item in chunk_items:
- items.extend(item)
+ for item_id in item_ids_order:
+ item = item_by_id.get(item_id)
+ if item is not None:
+ items.append(item)
+
yatest_logger.info("Modulo %s tests are: %s", modulo_index, chunk_items)
if config.option.mode == yatest_lib.ya.RunMode.Run: