You are trying to patch the __init__
method; the fact that there is a __call__
method as well makes no odds here.
You'd normally decorate the __init__
method instead, using a regular (function) decorator; if you have to use a class decorator, then use one that subclasses the decorated class:
def init_service(cls):
class InitService(cls):
def __init__(self, port='ignored'):
super(InitService).__init__(5432)
return InitService