Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`python`.`monkey`.`MonkeyPatcher``

class documentation

`class MonkeyPatcher: (source)`

Constructor: `MonkeyPatcher(*patches)`

View In Hierarchy

Cover up attributes with new objects. Neat for monkey-patching things for unit-testing purposes.

Method | `__exit__` | Undocumented
Method | `__init__` | Undocumented
Method | `addPatch` | Add a patch so that the attribute `name` on `obj` will be assigned to `value` when `patch` is called or during `runWithPatches`.
Method | `patch` | Apply all of the patches that have been specified with `addPatch`. Reverse this operation using `restore`.
Method | `restore` | Restore all original values to any patched objects.
Method | `runWithPatches` | Apply each patch already specified. Then run the function f with the given args and kwargs. Restore everything when done.
Method | `_alreadyPatched` | Has the `name` attribute of `obj` already been patched by this patcher?
Instance Variable | `_originals` | Undocumented
Instance Variable | `_patchesToApply` | Undocumented

def __exit__(self, excType=None, excValue=None, excTraceback=None): (source)

Undocumented

def __init__(self, *patches): (source)

Undocumented

def addPatch(self, obj, name, value): (source)

Add a patch so that the attribute `name` on `obj` will be assigned to `value` when `patch` is called or during `runWithPatches`.

You can restore the original values with a call to restore().

def patch(self): (source)

Apply all of the patches that have been specified with `addPatch`. Reverse this operation using `restore`.

def restore(self): (source)

Restore all original values to any patched objects.

def runWithPatches(self, f, *args, **kw): (source)

Apply each patch already specified. Then run the function f with the given args and kwargs. Restore everything when done.

def _alreadyPatched(self, obj, name): (source)

Has the `name` attribute of `obj` already been patched by this patcher?

_originals: `list` = (source)

Undocumented

_patchesToApply: `list` = (source)

Undocumented