Skip to content

Commit 24a0298

Browse files
committed
test_itertoolz: Add some unit tests for split.
1 parent e19b34b commit 24a0298

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

toolz/tests/test_itertoolz.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
concat, concatv, interleave, unique,
99
isiterable, getter,
1010
mapcat, isdistinct, first, second,
11-
nth, take, tail, drop, interpose, get,
11+
nth, take, tail, drop, split, interpose, get,
1212
rest, last, cons, frequencies,
1313
reduceby, iterate, accumulate,
1414
sliding_window, count, partition,
@@ -172,6 +172,28 @@ def test_drop():
172172
assert list(drop(1, (3, 2, 1))) == list((2, 1))
173173

174174

175+
def test_split():
176+
l = [10, 20, 30, 40, 50]
177+
assert list(map(tuple, split(0, l))) == [tuple(),
178+
(10,),
179+
(20, 30, 40, 50)]
180+
181+
l = [10, 20, 30, 40, 50]
182+
assert list(map(tuple, split(4, l))) == [(10, 20, 30, 40,),
183+
(50,),
184+
tuple()]
185+
186+
l = [10, 20, 30, 40, 50]
187+
assert list(map(tuple, split(5, l))) == [(10, 20, 30, 40, 50),
188+
tuple(),
189+
tuple()]
190+
191+
l = [10, 20, 30, 40, 50]
192+
assert list(map(tuple, split(2, l))) == [(10, 20),
193+
(30,),
194+
(40, 50)]
195+
196+
175197
def test_take_nth():
176198
assert list(take_nth(2, 'ABCDE')) == list('ACE')
177199

0 commit comments

Comments
 (0)