~hlaf/mockproc/windows_support

« back to all changes in this revision

Viewing changes to doc/index.rst

  • Committer: Mike C. Fletcher
  • Date: 2012-01-18 23:47:31 UTC
  • Revision ID: mcfletch@vrplumber.com-20120118234731-crei6cq6s6eyfzm9
Some initial usage documentation

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
5
 
 
6
 
Welcome to MockProc's documentation!
7
 
====================================
 
1
MockProc for Python, Subprocess Stubs for Tests
 
2
===============================================
 
3
 
 
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.
 
7
 
 
8
Standard usage:
 
9
 
 
10
.. code-block:: python
 
11
 
 
12
    from mockproc import mockprocess
 
13
    class Test( unittest.TestCase ):
 
14
        def setUp( self ):
 
15
            self.scripts = mockprocess.MockProc()
 
16
        def tearDown( self ):
 
17
            self.scripts.__exit__()
 
18
        
 
19
        def test_subprocess_fail( self ):
 
20
            self.scripts.append( 'process-name', returncode=1 )
 
21
            self.scripts.__enter__()
 
22
            
 
23
            run_and_handle_result()
 
24
        
 
25
        def test_subprocess_output( self ):
 
26
            self.scripts.append( 'process-name', returncode=0, stdout="output to process" )
 
27
            self.scripts.__enter__()
 
28
            
 
29
            run_and_handle_result()
 
30
        
 
31
        def test_custom_script( self ):
 
32
            self.scripts.append('process-name',returncode = 0,script="""#! /usr/bin/env python
 
33
import time 
 
34
time.sleep( 2.0 )
 
35
""")
 
36
            run_and_handle_timeout()
8
37
 
9
38
Contents:
10
39