def observed(fn):
    def observe(*args, **kwargs):
        """
        Inject observer
        """
        context = args[0]

        if not hasattr(context, 'observer'):
            context.observer = EventListener()

            if not hasattr(context, 'model'):
                context.model = Model()

            context.model.register_event_listener(context.observer)

        return fn(*args, **kwargs)

    return observe
Decorator to inject observer
dataset/ETHPy150Open tuturto/pyherc/src/pyherc/test/bdd/features/helpers/events.py/observed