Ejemplo n.º 1
0
def test_many_short():
    stream = Stream.from_iterable(range(100))
    validate_stream(stream, 100, int)

    stream_repr = repr(stream)
    validate_header(stream_repr)
    assert ', ' in stream_repr
    assert stream_repr.endswith('...')
Ejemplo n.º 2
0
def test_few_short():
    stream = Stream.from_iterable(range(3))
    validate_stream(stream, 3, int)

    stream_repr = repr(stream)
    validate_header(stream_repr)
    assert ', ' in stream_repr
    assert not stream_repr.endswith('...')
Ejemplo n.º 3
0
def test_from_iterable_tuple():
    values = [
        [1, 2, 3],
        ['a', 'b', 'c'],
        ['x', 'y', 'z'],
    ]

    iter_stream = Stream.from_iterable(values)
    validate_stream(iter_stream, 3, list, 3)
Ejemplo n.º 4
0
def test_many_long():
    long_string = string.ascii_letters * 2

    stream = Stream.from_iterable([long_string,] * 100)
    validate_stream(stream, 100, str, len(long_string))

    stream_repr = repr(stream)
    validate_header(stream_repr)
    assert ',\n' in stream_repr
    assert stream_repr.endswith('...')
Ejemplo n.º 5
0
def test_from_iterable():
    iter_stream = Stream.from_iterable([1, 2, 3])
    validate_stream(iter_stream, 3, int)
Ejemplo n.º 6
0
def test_no_func():
    none_stream = Stream.from_iterable([1, 2, None, 3, 4, None, 5])
    validate_stream(none_stream, 7, (int, type(None)))

    filter_stream = none_stream.filter()
    validate_stream(filter_stream, 5, int)
Ejemplo n.º 7
0
def test_empty_tuple_stream():
    empty_tuple_stream = Stream.from_iterable(())
    unbatched_stream = empty_tuple_stream.unbatch()
    validate_stream(unbatched_stream, 0, object)