Module p.u.t.mock

Part of pida.utils.testing

Mock object library for Python. Mock objects can be used when unit testing to remove a dependency on another production class. They are typically used when the dependency would either pull in lots of other classes, or significantly slow down the execution of the test. They are also used to create exceptional conditions that cannot otherwise be easily triggered in the class under test.
Line # Kind Name Docs
60 Class MockInterfaceError Undocumented
63 Class Mock The Mock class emulates any other class for testing purposes.
171 Function _getNumPosSeenAndCheck Positional arguments can appear as call parameters either named as
192 Class MockCall MockCall records the name and parameters of a call to an instance
241 Class MockCallable Intercepts the call and records it, then delegates to either the mock's
290 Function _findFunc Depth first search for a method with a given name.
302 Class ReturnValuesBase Undocumented
311 Class ReturnValues Undocumented
316 Class ReturnIterator Undocumented
321 Function expectParams check that the callObj is called with specified params and keywords
329 Function expectAfter check that the function is only called after all the functions in 'methods'
342 Function expectException raise an exception when the method is called
350 Function expectParam check that the callObj is called with parameter specified by paramIdx (a position index or keyword)
360 Function EQ Undocumented
365 Function NE Undocumented
370 Function GT Undocumented
375 Function LT Undocumented
380 Function GE Undocumented
385 Function LE Undocumented
390 Function AND Undocumented
398 Function OR Undocumented
406 Function NOT Undocumented
411 Function MATCHES Undocumented
417 Function SEQ Undocumented
427 Function IS Undocumented
432 Function ISINSTANCE Undocumented
437 Function ISSUBCLASS Undocumented
442 Function CONTAINS Undocumented
447 Function IN Undocumented
452 Function HASATTR Undocumented
457 Function HASMETHOD Undocumented
def _getNumPosSeenAndCheck(numPosCallParams, callKwParams, args, varkw):
Positional arguments can appear as call parameters either named as a named (keyword) parameter, or just as a value to be matched by position. Count the positional arguments that are given by either keyword or position, and check for duplicate specifications. Also check for arguments specified by keyword that do not appear in the method's parameter list.
def _findFunc(cl, name):
Depth first search for a method with a given name.
def expectParams(*params, **keywords):
check that the callObj is called with specified params and keywords
def expectAfter(*methods):
check that the function is only called after all the functions in 'methods'
def expectException(exception, *args, **kwargs):
raise an exception when the method is called
def expectParam(paramIdx, cond):
check that the callObj is called with parameter specified by paramIdx (a position index or keyword) fulfills the condition specified by cond. cond is a function that takes a single argument, the value to test.
def EQ(value):
Undocumented
def NE(value):
Undocumented
def GT(value):
Undocumented
def LT(value):
Undocumented
def GE(value):
Undocumented
def LE(value):
Undocumented
def AND(*condlist):
Undocumented
def OR(*condlist):
Undocumented
def NOT(cond):
Undocumented
def MATCHES(regex, *args, **kwargs):
Undocumented
def SEQ(*sequence):
Undocumented
def IS(instance):
Undocumented
def ISINSTANCE(class_):
Undocumented
def ISSUBCLASS(class_):
Undocumented
def CONTAINS(val):
Undocumented
def IN(container):
Undocumented
def HASATTR(attr):
Undocumented
def HASMETHOD(method):
Undocumented
API Documentation for PIDA, generated by pydoctor.