def test_iter_simple_repeatable(mock_files): stream = Stream(glob.glob(mock_files['dirpath']), repeatable=True) result = [rst for rst in stream] assert (result == glob.glob(mock_files['dirpath'])) # Repeatable result = [rst for rst in stream] assert (result == glob.glob(mock_files['dirpath']))
def test_simple_filter_no_repeatable(mock_files): stream = Stream(glob.glob(mock_files['dirpath'])) stream.do(read_file, chain=True) stream.filter(lambda line: not line.startswith('9')) assert (len([i for i in stream ]) == (NUM_FILES * NUM_LINES) - mock_files['startswith9']) assert (len([i for i in stream]) == 0)
def test_single_do_repeatable_nochain(mock_files): stream = Stream(glob.glob(mock_files['dirpath']), repeatable=True) stream.do(read_file) assert (len([i for i in stream]) == NUM_FILES) assert (len([i for i in stream]) == NUM_FILES)
def test_single_do_no_repeatable(mock_files): stream = Stream(glob.glob(mock_files['dirpath'])) stream.do(read_file, chain=True) assert (len([i for i in stream]) == NUM_FILES * NUM_LINES) assert (len([i for i in stream]) == 0)