From 92e49a770ce5cabd47a043414161ef6ac63f4742 Mon Sep 17 00:00:00 2001 From: EspenAlbert Date: Thu, 11 Jan 2024 19:54:49 +0700 Subject: [PATCH] test: add a test for iter_slices --- .../tests/test_zero_3rdparty/test_iter_utils.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/zero_3rdparty/tests/test_zero_3rdparty/test_iter_utils.py b/zero_3rdparty/tests/test_zero_3rdparty/test_iter_utils.py index d12bf64..4f66ea3 100644 --- a/zero_3rdparty/tests/test_zero_3rdparty/test_iter_utils.py +++ b/zero_3rdparty/tests/test_zero_3rdparty/test_iter_utils.py @@ -1,4 +1,5 @@ -from zero_3rdparty.iter_utils import public_values, unique_instance_iter, want_list +from zero_3rdparty.iter_utils import public_values, unique_instance_iter, want_list, \ + iter_slices class NonSortedClassVars: @@ -50,3 +51,15 @@ def a(): def test_want_list_from_tuple(): assert want_list((1, 2, 3)) == [1, 2, 3] + + +def test_iter_slices(): + full_list = list(range(1, 11)) + slices = [] + for slice in iter_slices(full_list, max=2): + slices.append(slice) + assert slices == [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] + slices.clear() + for slice in iter_slices(full_list, max=3): + slices.append(slice) + assert slices == [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]