jerry-git / jerry-git/pytest-split

feature request: order tests by slowest-first

未关闭
#89 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
325
派生
56
PR 合并指标
30 天内没有已合并 PR

描述

in long running test suites (especially with xdist), it's useful to run the slowest tests first so that you end up with better load. the following code seems to do so:
```
def pytest_collection_modifyitems(config, items):
try:
with open(".test_durations") as f:
s = f.read()
durations = json.loads(s)
except FileNotFoundError:
durations = {}

timings = {}
for item in items:
path, _, reqname = item.location
request_id = f"{path}::{reqname}"
timing = durations.get(request_id, None)
if timing is not None:
timings[item] = timing

meantime = sum(timings.values()) / len(timings)
# sort by highest time first
items.sort(key=lambda item: -timings.get(item, meantime))
```
but i was thinking it might be good for this to be available in the pytest-split plugin itself, so we don't need to add this same function across different projects.

alternatively, i was thinking publishing this as a plugin myself, if pytest-split does not want to add it.

贡献指南

这个仓库没有索引到贡献指南

调研方向

首先阅读 pytest-split 在 collection 修改以及现有 .test_durations 处理方面的插件入口点。检查当前如何实现与 xdist 相关的拆分,以及所提议的 pytest_collection_modifyitems hook 是否适合该插件的流程。当插件能够在不要求重复编写项目特定代码的情况下,按最慢优先的顺序排列测试时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
testing-qa
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。