Commit 27c0b505 authored by Julien Muchembled's avatar Julien Muchembled

tests: implement default __str__ & __repr__ for Mock objects

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2719 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 13e86665
......@@ -52,6 +52,18 @@ debug.register()
debug.ENABLED = False
logger.PACKET_LOGGER.enable(True)
def mockDefaultValue(name, function):
def method(self, *args, **kw):
if name in self.mockReturnValues:
return self.__getattr__(name)(*args, **kw)
return function(self, *args, **kw)
method.__name__ = name
setattr(Mock, name, method)
mockDefaultValue('__repr__', lambda self:
'<%s object at 0x%x>' % (self.__class__.__name__, id(self)))
mockDefaultValue('__str__', repr)
def buildUrlFromString(address):
try:
socket.inet_pton(socket.AF_INET6, address)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment