1
.. MockProc documentation master file, created by
2
sphinx-quickstart on Wed Jan 18 18:35:11 2012.
3
You can adapt this file completely to your liking, but it should at least
4
contain the root `toctree` directive.
6
Welcome to MockProc's documentation!
7
====================================
1
MockProc for Python, Subprocess Stubs for Tests
2
===============================================
4
MockProc is a mechanism that allows you to stub out subprocesses during testing
5
to test handling of subprocess behaviours including timeout handling, output
6
processing, input processing and the like.
10
.. code-block:: python
12
from mockproc import mockprocess
13
class Test( unittest.TestCase ):
15
self.scripts = mockprocess.MockProc()
17
self.scripts.__exit__()
19
def test_subprocess_fail( self ):
20
self.scripts.append( 'process-name', returncode=1 )
21
self.scripts.__enter__()
23
run_and_handle_result()
25
def test_subprocess_output( self ):
26
self.scripts.append( 'process-name', returncode=0, stdout="output to process" )
27
self.scripts.__enter__()
29
run_and_handle_result()
31
def test_custom_script( self ):
32
self.scripts.append('process-name',returncode = 0,script="""#! /usr/bin/env python
36
run_and_handle_timeout()