Package Products :: Package ZenUtils :: Module mock :: Class MockObject
[hide private]
[frames] | no frames]

Class MockObject

source code

object --+
         |
        MockObject

An object that takes a hashmap and uses it for the attributes on the object. Setting attributes is ignored. Retrieving an unknown attribute returns an empty MockObject. The key 'return__' is special in that its corresponding value will be returned if the object is called as a function.

>>> a=MockObject(b='c')
>>> a.b
'c'
>>> a.d
{}
>>> a.d.e
{}
>>> x=MockObject(return__=5)
>>> y=MockObject(z=x)
>>> y.z()
5
Instance Methods [hide private]
 
__call__(self, *args, **kw) source code
 
__init__(self, **kw) source code
 
__getattr__(self, item) source code
 
__repr__(self) source code
 
__str__(self) source code
Method Details [hide private]

__init__(self, **kw)
(Constructor)

source code 
Overrides: object.__init__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 
Overrides: object.__repr__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 
Overrides: object.__str__
(inherited documentation)