Skip to content

Commit

Permalink
added tuple cycle test
Browse files Browse the repository at this point in the history
  • Loading branch information
bmcfee committed Mar 2, 2017
1 parent 632f118 commit 118e912
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,33 @@ def test_streamer_cycle():
assert (len(data_results) == count_max and all(data_results))


@pytest.mark.parametrize('items',
[['X'], ['Y'], ['X', 'Y'], ['Y', 'X'],
pytest.mark.xfail([],
raises=pescador.PescadorError)])
def test_streamer_cycle_tuples(items):
"""Test that a limited streamer will die and restart automatically."""
stream_len = 10
streamer = pescador.Streamer(T.__zip_generator, 10, 2, 3)
assert streamer.stream_ is None

# Exhaust the stream once.
query = list(streamer.generate())
assert stream_len == len(query)

# Now, generate from it infinitely using cycle.
# We're going to assume "infinite" == > 5*stream_len
count_max = 5 * stream_len

data_results = []
kwargs = dict(cycle=True)
for i, x in enumerate(streamer.tuples(*items, **kwargs)):
data_results.append((isinstance(x, tuple)))
if (i + 1) >= count_max:
break
assert (len(data_results) == count_max and all(data_results))


def test_streamer_bad_function():

def __fail():
Expand Down

0 comments on commit 118e912

Please sign in to comment.