l.t.f.FakeMethod : class documentation

Part of lp.testing.fakemethod View In Hierarchy

Known subclasses: lp.archivepublisher.tests.test_signing.FakeMethodCallLog

Catch any function or method call, and record the fact.

Use this for easy stubbing. The call operator can return a fixed value, or raise a fixed exception object.

This is useful when unit-testing code that does things you don't want to integration-test, e.g. because it wants to talk to remote systems.

Method __init__ Set up a fake function or method.
Method __call__ Catch an invocation to the method.
Method call_count Undocumented
Method extract_args Return just the calls' positional-arguments tuples.
Method extract_kwargs Return just the calls' keyword-arguments dicts.
def __init__(self, result=None, failure=None):
Set up a fake function or method.
ParametersresultValue to return.
failureException to raise.
def __call__(self, *args, **kwargs):
Catch an invocation to the method.

Increment call_count, and adds the arguments to calls.

Accepts any and all parameters. Raises the failure passed to the constructor, if any; otherwise, returns the result value passed to the constructor.

@property
def call_count(self):
Undocumented
def extract_args(self):
Return just the calls' positional-arguments tuples.
def extract_kwargs(self):
Return just the calls' keyword-arguments dicts.
API Documentation for Launchpad, generated by pydoctor at 2022-06-16 00:00:12.