Ejemplo n.º 1
0
def test_infinite():
    stream = streams.wrap(itertools.count())

    if streams._py_major == 2 and streams._py_minor < 7:

        def count(start, step):
            while True:
                yield start
                start += step
    else:
        count = itertools.count

    utils.testInfinite(count(1, 2), stream.filter(lambda x: x % 2 == 1))
Ejemplo n.º 2
0
def test_exact_page():
    stream = streams.wrap(iter([0, 1, 2, 3])).paginate(2)
    layers = 0
    for l in stream:
        utils.testWrapped(l)
        values = 0
        for v in l:
            assert v == values + (2 * layers)
            values += 1
        assert values == 2
        layers += 1
    assert layers == 2

    utils.testEmpty(stream)
Ejemplo n.º 3
0
def test_infinite():
    def infinte():
        i = 0
        while True:
            yield i
            i += 1

    def infinte_str():
        i = 0
        while True:
            yield str(i)
            i += 1

    stream = streams.wrap(infinte())
    utils.testInfinite(infinte_str(), stream.map(str))
Ejemplo n.º 4
0
def test_lazy():
    size = 4
    stream = streams.wrap(utils.lazy_bomb(size / 2, [1, 2])).flatten()
    for i in range(size):
        next(stream)
Ejemplo n.º 5
0
def test_basic():
    stream = streams.wrap(iter([0, 1, 2]))
    utils.checkFinite(['0', '1', '2'], stream.map(str))
Ejemplo n.º 6
0
def test_infinite():
    stream = streams.wrap(utils.infinte())

    utils.testInfinite(utils.infinte(), stream)
Ejemplo n.º 7
0
def test_empty():
    stream = streams.wrap(iter([]))

    utils.testEmpty(stream.flatten())
Ejemplo n.º 8
0
def test_basic():
    sample_list = [1, 2, 3]
    stream = streams.wrap(iter(sample_list))

    utils.checkFinite([1, 3], stream.filter(lambda x: x % 2 == 1))
Ejemplo n.º 9
0
def test_multi():
    stream1 = streams.wrap(iter([0, 1, 2]))
    stream2 = ['0', '1', '2']
    stream3 = ["x", "y", "z"]
    result = [(0, '0', "x"), (1, '1', "y"), (2, '2', "z")]
    utils.checkFinite(result, stream1.zip(stream2, stream3))
Ejemplo n.º 10
0
def test_zero():
    sample_list = [1, 2, 3, 4, 5]
    stream = streams.wrap(iter(sample_list))

    utils.testEmpty(stream.limit(0))
Ejemplo n.º 11
0
def test_lazy():
    size = 4
    stream = streams.wrap(utils.lazy_bomb(size)).limit(5)
    for i in range(size):
        next(stream)
Ejemplo n.º 12
0
def test_infinite():
    stream = streams.wrap(utils.infinte())

    utils.checkFinite(['a', 'a', 'a', 'a'], stream.limit(4))
Ejemplo n.º 13
0
def test_empty():
    stream = streams.wrap(iter([]))

    utils.testEmpty(stream.limit(4))
Ejemplo n.º 14
0
def test_high_limit():
    sample_list = [1, 2, 3, 4, 5]
    stream = streams.wrap(iter(sample_list))
    utils.checkFinite(sample_list, stream.limit(6))
Ejemplo n.º 15
0
def test_basic():
    sample_list = [1, 2, 3, 4, 5]
    stream = streams.wrap(iter(sample_list))
    utils.checkFinite(sample_list[:4], stream.limit(4))
Ejemplo n.º 16
0
def test_empty():
    stream = streams.wrap(iter([]))
    finite = streams.wrap([1, 2, 3])

    utils.testEmpty(stream.zip(finite))
    utils.testEmpty(finite.zip(stream))
Ejemplo n.º 17
0
def test_empty():
    stream = streams.wrap(iter([]))

    utils.testEmpty(stream.map(str))
Ejemplo n.º 18
0
def test_empty():
    stream = streams.wrap(iter([]))

    utils.testEmpty(stream.filter(lambda x: x % 2 == 1))
Ejemplo n.º 19
0
def test_lazy():
    size = 4
    stream = streams.wrap(utils.lazy_bomb(size)).map(lambda x: x)
    for i in range(size):
        next(stream)
Ejemplo n.º 20
0
def test_empty():
    stream = streams.wrap(iter([])).paginate(1)

    utils.testEmpty(stream)
Ejemplo n.º 21
0
def test_basic():
    sample_list = [[1, 2], [3, 4]]
    stream = streams.wrap(iter(sample_list))

    utils.checkFinite([1, 2, 3, 4], stream.flatten())
Ejemplo n.º 22
0
def test_basic():
    stream1 = streams.wrap(iter([0, 1, 2]))
    stream2 = ['0', '1', '2']
    result = [(0, '0'), (1, '1'), (2, '2')]
    utils.checkFinite(result, stream1.zip(stream2))
Ejemplo n.º 23
0
def test_lazy():
    size = 4
    stream = streams.wrap(utils.lazy_bomb(size)).filter(lambda x: True)
    for i in range(size):
        next(stream)
Ejemplo n.º 24
0
def test_recursive():
    sample_list = [streams.wrap([1, 2]), streams.wrap([3])]
    stream = streams.wrap(iter(sample_list))

    utils.checkFinite([1, 2, 3], stream.flatten())
Ejemplo n.º 25
0
def test_infinite():
    stream = streams.wrap(utils.infinte(['a']))
    utils.testInfinite(utils.infinte(), stream.flatten())

    stream = streams.wrap([utils.infinte(), utils.infinte()])
    utils.testInfinite(utils.infinte(), stream.flatten())
Ejemplo n.º 26
0
def test_basic():
    sample_list = [1, 2, 3]
    stream = streams.wrap(iter(sample_list))

    utils.checkFinite(sample_list, stream)