Codebase list python-procrunner / d944faf7-9a03-457d-bb65-050eec4c9252/upstream/2.3.1+git20221110.1.77d55b7 docs / usage.rst
d944faf7-9a03-457d-bb65-050eec4c9252/upstream/2.3.1+git20221110.1.77d55b7

Tree @d944faf7-9a03-457d-bb65-050eec4c9252/upstream/2.3.1+git20221110.1.77d55b7 (Download .tar.gz)

usage.rst @d944faf7-9a03-457d-bb65-050eec4c9252/upstream/2.3.1+git20221110.1.77d55b7raw · history · blame

=====
Usage
=====

To use ProcRunner in a project::

    import procrunner
    result = procrunner.run(['/bin/ls', '/some/path/containing spaces'])

To test for successful completion::

    assert not result.returncode
    assert result.returncode == 0  # alternatively
    result.check_returncode()  # raises subprocess.CalledProcessError()

To test for no STDERR output::

    assert not result.stderr
    assert result.stderr == b''  # alternatively

To run with a specific environment variable set::

    result = procrunner.run(..., environment_override={ 'VARIABLE': 'value' })

To run with a specific environment::

    result = procrunner.run(..., environment={ 'VARIABLE': 'value' })

To run in a specific directory::

    result = procrunner.run(..., working_directory='/some/path')