I'm a relative newcomer to python and I'm just wondering if there is some equivalent to the map coercion feature available in groovy.
For context, I am writing a unit test and want to mock a class with a simple two method interface, in groovy I would do the following:
mock = [apply:{value -> return value*2 }, isValid:{return true}]
testObject.applyMock(mock)
i.e, mock can be treated as an object with a class like:
class mock:
def apply(self, value):
return value *2
def isValid(self):
return true
Is there a nice pythonic way to achieve this?
Cheers Alex