Welcome to PatchIO’s documentation!

Contents:

PatchIO

https://img.shields.io/pypi/v/patchio.svg https://travis-ci.org/treyhunner/patchio.png?branch=master https://codecov.io/github/treyhunner/patchio/coverage.svg?branch=master

Python monkey-patching utilities

Pull requests are welcome. Read the CONTRIBUTING file for tips on submitting a pull request.

Installation

At the command line:

$ pip install patchio

Usage

To use PatchIO in a project:

import patchio

Command-Line Arguments

You can use patch_args to monkey patch command-line arguments.

This utility can be used as a context manager:

import sys
with patch_args(["hello", "world"]) as args:
    assert " ".join(sys.argv[1:]) == "hello world"
    assert args == sys.argv

This utility can also be used as a decorator:

import sys
@patch_args(["hello", "world"])
def get_args():
    return sys.argv
assert " ".join(get_args()) == "hello world"

Contributing

Below is a list of tips for submitting issues and pull requests. These are suggestions and not requirements.

Submitting Issues

Issues are often easier to reproduce/resolve when they have:

  • A pull request with a failing test demonstrating the issue
  • A code example that produces the issue consistently
  • A traceback (when applicable)

Pull Requests

When creating a pull request, try to:

  • Write tests if applicable
  • Note important changes in the CHANGES file
  • Update the README file if needed
  • Update the documentation if needed
  • Add yourself to the AUTHORS file
  • Conform to PEP8 for code contributions

Testing

You will need tox and coverage installed to run the tests on your code:

$ pip install tox coverage

To run the tests and generate a coverage report (in htmlcov directory):

$ make test-all

Please note: Before a pull request can be merged, all tests must pass and code/branch coverage in tests must be 100%.

Credits

Authors and contributors to patchio (listed alphabetically):

Indices and tables