def test_close_process_when_exception():
 exc = Exception('boom')
 with pytest.raises(Exception) as e:
  with pipeline.get_cat_pipeline(pipeline.PIPE, pipeline.PIPE) as pl:
   assert (len(pl.commands) == 1)
   assert (pl.commands[0]._process.poll() is None)
   raise exc
 assert (e.value is exc)
 pipeline_wait(pl)

def test_close_process_when_exception ( ) : exc = Exception ( 'boom' ) with pytest . raises ( Exception ) as e : with pipeline . get_cat_pipeline ( pipeline . PIPE , pipeline . PIPE ) as pl : assert ( len ( pl . commands ) == 1 ) assert ( pl . commands [ 0 ] . _process . poll ( ) is None ) raise exc assert ( e . value is exc ) pipeline_wait ( pl )
process leaks must not occur when an exception is raised .