jerry-git / jerry-git/pytest-split

feature request: order tests by slowest-first

オープン
#89 コメント 3 件 リアクション 0 件 担当者 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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。