示例#1
0
 def test_take_first(self):
     assert [0, 1, 2] == list(take_first(3)(range(10)))
示例#2
0
 def test_format_generator(self):
     f = StringFormatter('{0} + {0} = {1}')
     assert f(range(1, 3)) == '1 + 1 = 2'
示例#3
0
 def test_input(self):
     result = range(5) > where(X % 2) | list
     assert result == [1, 3]
示例#4
0
 def test_iterable(self):
     assert (range(10000) > drop_first(9999) | list) == [9999]
示例#5
0
 def test_take_first(self):
     assert [0, 1, 2] == list(take_first(3)(range(10)))
示例#6
0
 def _drop_first(iterable):
     g = (x for x in range(1, count + 1))
     return dropwhile(lambda i: unless(StopIteration, lambda: next(g))(),
                      iterable)
示例#7
0
 def test_iterable(self):
     assert (range(10000) > drop_first(9999) | list) == [9999]
示例#8
0
 def test_input(self):
     result = range(5) > where(X % 2) | list
     assert result == [1, 3]
示例#9
0
 def test_format_generator(self):
     f = StringFormatter('{0} + {0} = {1}')
     assert f(range(1, 3)) == '1 + 1 = 2'
示例#10
0
文件: utils.py 项目: 0101/pipetools
 def _drop_first(iterable):
     g = (x for x in range(1, count + 1))
     return dropwhile(
         lambda i: unless(StopIteration, lambda: next(g))(), iterable)
示例#11
0
def test_nested():

    f = DSBuilder({'seq': [X * y for y in range(4)]})

    assert f(2) == {'seq': [0, 2, 4, 6]}