refactoring; additional buffer test

This commit is contained in:
Matthias Bisping 2022-05-07 00:29:58 +02:00
parent 1e21913e37
commit 8c1ad64464
4 changed files with 8 additions and 1 deletions

View File

@ -1,5 +1,5 @@
from itertools import chain
from typing import Union, Any, Iterable, Callable
from typing import Union, Any
from pyinfra.server.dispatcher.dispatcher import Nothing

View File

View File

@ -17,3 +17,10 @@ def test_buffer():
reverse_buffer = bufferize(compose(reverse_buffer, list), buffer_size=3)
ys = lmapcat(reverse_buffer, range(10))
assert ys == [2, 1, 0, 5, 4, 3, 8, 7, 6]
def buffer_sum(xs):
return [sum(xs)]
buffer_sum = bufferize(buffer_sum, buffer_size=3)
ys = lmapcat(buffer_sum, range(10))
assert ys == [0, 0, 3, 0, 0, 12, 0, 0, 21, 0]