old_contents: from __future__ import print_function
  import pytest
  from plumbium.processresult import record, pipeline, call
  
  
  class DummyRecorder(object):
      def write(self, results):
          self.results = results
  
  
  @pytest.fixture
  def simple_pipeline():
      @record('an_output')
      def recorded_function():
          call(['echo', 'test output'])
          return 'test_result'
  
      def a_pipeline():
          recorded_function()
  
      return a_pipeline
  
  
  @pytest.fixture
  def failing_pipeline():
      @record('an_output')
      def recorded_function():
          raise IOError
  
      def a_pipeline():
          recorded_function()
  
      return a_pipeline
  
  
  def test_result(simple_pipeline, tmpdir):
      with tmpdir.as_cwd():
          pipeline.run('test', simple_pipeline, str(tmpdir))
          print(pipeline.results)
          assert pipeline.results[0]['an_output'] == 'test_result'
  
  
  def test_stdout_captured(simple_pipeline, tmpdir):
      with tmpdir.as_cwd():
          pipeline.run('test', simple_pipeline, str(tmpdir))
          proc = pipeline.results[0].as_dict()
          assert proc['printed_output'] == 'test output\n'
  
  
  def test_exception_captured(failing_pipeline, tmpdir):
      with tmpdir.as_cwd():
          pipeline.run('test', failing_pipeline, str(tmpdir))
          proc = pipeline.results[0].as_dict()
          assert 'IOError' in proc['exception']
  
  
  def test_save_filename(simple_pipeline, tmpdir):
      with tmpdir.as_cwd():
          pipeline.run(
              'test',
              simple_pipeline,
              str(tmpdir),
              metadata={'test': 1},
              filename='result_file_{metadata[test]:03d}'
          )
          assert 'result_file_001.tar.gz' in [f.basename for f in tmpdir.listdir()]
  
new_contents: from __future__ import print_function
  import pytest
  from plumbium.processresult import record, pipeline, call
  
  
  class DummyRecorder(object):
      def write(self, results):
          self.results = results
  
  
  @pytest.fixture
  def simple_pipeline():
      @record('an_output')
      def recorded_function():
          call(['echo', 'test output'])
          return 'test_result'
  
      def a_pipeline():
          recorded_function()
  
      return a_pipeline
  
  
  @pytest.fixture
  def input_pipeline():
      @record('an_output')
      def recorded_function(x):
          call(['echo', str(x)])
  
      def a_pipeline(x):
          recorded_function(x)
  
      return a_pipeline
  
  
  @pytest.fixture
  def failing_pipeline():
      @record('an_output')
      def recorded_function():
          raise IOError
  
      def a_pipeline():
          recorded_function()
  
      return a_pipeline
  
  
  def test_result(simple_pipeline, tmpdir):
      with tmpdir.as_cwd():
          pipeline.run('test', simple_pipeline, str(tmpdir))
          print(pipeline.results)
          assert pipeline.results[0]['an_output'] == 'test_result'
  
  
  def test_input(input_pipeline, tmpdir):
      with tmpdir.as_cwd():
          pipeline.run('test', input_pipeline, str(tmpdir), 3)
          proc = pipeline.results[0].as_dict()
          assert proc['printed_output'] == '3\n'
  
  
  def test_stdout_captured(simple_pipeline, tmpdir):
      with tmpdir.as_cwd():
          pipeline.run('test', simple_pipeline, str(tmpdir))
          proc = pipeline.results[0].as_dict()
          assert proc['printed_output'] == 'test output\n'
  
  
  def test_exception_captured(failing_pipeline, tmpdir):
      with tmpdir.as_cwd():
          pipeline.run('test', failing_pipeline, str(tmpdir))
          proc = pipeline.results[0].as_dict()
          assert 'IOError' in proc['exception']
  
  
  def test_save_filename(simple_pipeline, tmpdir):
      with tmpdir.as_cwd():
          pipeline.run(
              'test',
              simple_pipeline,
              str(tmpdir),
              metadata={'test': 1},
              filename='result_file_{metadata[test]:03d}'
          )
          assert 'result_file_001.tar.gz' in [f.basename for f in tmpdir.listdir()]
  
subject: Add a test of a pipeline with an input