From 31fafaea932992e52cf10cb5cce06b67ec6d61f8 Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Fri, 18 Feb 2022 15:38:54 +0800 Subject: [PATCH] ci(pytest): reorder test sequence to run tests faster --- conftest.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/conftest.py b/conftest.py index 12a88a88a8..1bf5b55643 100644 --- a/conftest.py +++ b/conftest.py @@ -152,11 +152,16 @@ def pytest_collection_modifyitems(config: Config, items: List[Function]) -> None if not target: return + # sort by file path and callspec.config + # implement like this since this is a limitation of pytest, couldn't get fixture values while collecting + # https://github.com/pytest-dev/pytest/discussions/9689 def _get_param_config(_item: Function) -> str: if hasattr(_item, 'callspec'): return _item.callspec.params.get('config', DEFAULT_SDKCONFIG) # type: ignore return DEFAULT_SDKCONFIG + items.sort(key=lambda x: (os.path.dirname(x.path), _get_param_config(x))) + # add markers for special markers for item in items: if 'supported_targets' in item_marker_names(item):