def _test(self, num): '''Insert ``num`` simple stages into the pipeline and run it.''' pipeline = Pipeline() assert pipeline.num_stages == 0 for n_stage in range(num): increment_stage = Increment() pipeline.append(increment_stage) assert pipeline.num_stages == n_stage + 1 data = PipelineData() data.items['num'] = 0 data = pipeline.run(data) assert data.items['num'] == num
def test_stage_as_function(self): '''Test the pipeline when only a simple function is added into the list of stages.''' pipeline = Pipeline() pipeline.append(function_stage) pipeline.append(Increment()) data = PipelineData() data.items['num'] = 0 data = pipeline.run(data) assert data.items['num'] == 2
def test_return_type(self): '''Test that a wrong return value is detected.''' def no_return_value(data_in): '''Does not return anything.''' print(data_in) def wrong_return_type(data_in): '''Wrong return type for the pipeline.''' return 'Wrong type' pipeline = Pipeline() pipeline.append(no_return_value) with pytest.raises(TypeError): pipeline.run(PipelineData()) pipeline = Pipeline() pipeline.append(wrong_return_type) with pytest.raises(TypeError): pipeline.run(PipelineData())