From f010995f7ac7937194fe0b6c3f4064ae0b238ffb Mon Sep 17 00:00:00 2001 From: Eran Krakovsky Date: Sun, 24 Jul 2022 12:07:40 +0300 Subject: [PATCH] fixed the issue of empty group this solution will create almost even distribution to the tests for all groups --- pytest_split_tests/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pytest_split_tests/__init__.py b/pytest_split_tests/__init__.py index bfe04ea..af8d351 100644 --- a/pytest_split_tests/__init__.py +++ b/pytest_split_tests/__init__.py @@ -10,13 +10,13 @@ def get_group_size(total_items, total_groups): """Return the group size.""" - return int(math.ceil(float(total_items) / total_groups)) + return float(total_items) / total_groups) def get_group(items, group_size, group_id): """Get the items from the passed in group based on group size.""" - start = group_size * (group_id - 1) - end = start + group_size + start = int(round(group_size * (group_id - 1))) + end = int(round(group_size * group_id)) if start >= len(items) or start < 0: raise ValueError("Invalid test-group argument")