From 4fd330b61ab37776562fbe02e1a7308640146d51 Mon Sep 17 00:00:00 2001 From: Brian Burgin Date: Wed, 25 Aug 2021 12:31:50 -0500 Subject: [PATCH] Handle case where remaining groups are empty --- pytest_split_tests/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pytest_split_tests/__init__.py b/pytest_split_tests/__init__.py index bfe04ea..393ad5a 100644 --- a/pytest_split_tests/__init__.py +++ b/pytest_split_tests/__init__.py @@ -18,8 +18,13 @@ def get_group(items, group_size, group_id): start = group_size * (group_id - 1) end = start + group_size - if start >= len(items) or start < 0: + if start < 0: + # invalid start index raise ValueError("Invalid test-group argument") + if start >= len(items): + # return empty group for groups that remain in the group count + # beyond the remaining items + return [] return items[start:end]