Skip to content

Commit

Permalink
Add additional test of recorders when a return is captured
Browse files Browse the repository at this point in the history
  • Loading branch information
jstutters committed Oct 27, 2016
1 parent c96b0f4 commit 8ce6c0f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/test_recorders.py
Expand Up @@ -16,6 +16,18 @@ def a_pipeline():
return a_pipeline


@pytest.fixture
def returning_pipeline():
@record('value')
def recorded_function():
return 5.12

def a_pipeline():
recorded_function()

return a_pipeline


def test_csvfile(simple_pipeline, tmpdir):
with tmpdir.as_cwd():
recorder = CSVFile(
Expand Down Expand Up @@ -54,3 +66,23 @@ def test_stdout(simple_pipeline, tmpdir, capsys):
)
out, err = capsys.readouterr()
assert out == 'id: 1\ndata: 6.35\n'


def test_return_record(returning_pipeline, tmpdir):
with tmpdir.as_cwd():
recorder = CSVFile(
'test.csv',
OrderedDict([
('data', lambda x: x['processes'][0]['returned'][0].strip())
])
)
pipeline.run(
'test',
returning_pipeline,
str(tmpdir),
metadata={'id': 1},
recorder=recorder
)
with open('test.csv') as f:
assert f.readline().strip() == 'data'
assert f.readline().strip() == '5.12'

0 comments on commit 8ce6c0f

Please sign in to comment.