@@ -34,6 +34,7 @@ async def reduction(x, y):
3434
3535@sync
3636async def test_accumulate_default ():
37+ """Test the default function of accumulate"""
3738 for itertype in (asyncify , list ):
3839 assert await a .list (a .accumulate (itertype ([0 , 1 ]))) == list (
3940 itertools .accumulate ([0 , 1 ])
@@ -53,10 +54,21 @@ async def test_accumulate_default():
5354
5455@sync
5556async def test_accumulate_misuse ():
57+ """Test wrong arguments to accumulate"""
5658 with pytest .raises (TypeError ):
5759 assert await a .list (a .accumulate ([]))
5860
5961
62+ @sync
63+ async def test_accumulate_initial ():
64+ """Test the `initial` argument to accumulate"""
65+ assert (
66+ await a .list (a .accumulate (asyncify ([1 , 2 , 3 ]), initial = None ))
67+ == await a .list (a .accumulate (asyncify ([1 , 2 , 3 ])))
68+ == list (itertools .accumulate ([1 , 2 , 3 ], initial = None ))
69+ )
70+
71+
6072batched_cases = [
6173 (range (10 ), 2 , [(0 , 1 ), (2 , 3 ), (4 , 5 ), (6 , 7 ), (8 , 9 )]),
6274 (range (10 ), 3 , [(0 , 1 , 2 ), (3 , 4 , 5 ), (6 , 7 , 8 ), (9 ,)]),
0 commit comments