Skip to content

Commit eb618f3

Browse files
committed
test_itertoolz: Add some unit tests for indices.
1 parent 4ad9583 commit eb618f3

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

toolz/tests/test_itertoolz.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from functools import partial
55
from random import Random
66
from pickle import dumps, loads
7-
from toolz.itertoolz import (remove, groupby, merge_sorted,
7+
from toolz.itertoolz import (remove, groupby, indices, merge_sorted,
88
concat, concatv, interleave, unique,
99
isiterable, getter,
1010
mapcat, isdistinct, first, second,
@@ -52,6 +52,31 @@ def test_groupby():
5252
assert groupby(iseven, [1, 2, 3, 4]) == {True: [2, 4], False: [1, 3]}
5353

5454

55+
def test_indices():
56+
assert list(indices(0)) == []
57+
assert list(indices(0, 5)) == []
58+
assert list(indices(5, 0)) == []
59+
60+
assert list(indices(5)) == [(0,),
61+
(1,),
62+
(2,),
63+
(3,),
64+
(4,)]
65+
66+
assert list(indices(1, 5)) == [(0, 0,),
67+
(0, 1,),
68+
(0, 2,),
69+
(0, 3,),
70+
(0, 4,)]
71+
72+
assert list(indices(3, 2)) == [(0, 0),
73+
(0, 1),
74+
(1, 0),
75+
(1, 1),
76+
(2, 0),
77+
(2, 1)]
78+
79+
5580
def test_groupby_non_callable():
5681
assert groupby(0, [(1, 2), (1, 3), (2, 2), (2, 4)]) == \
5782
{1: [(1, 2), (1, 3)],

0 commit comments

Comments
 (0)