@staticmethod
    def _stub_out(stubs, obj):
        orig_prepare = obj.prepare

        def prepare(self, *args, **kwargs):
            # Casts with fanout=True would throw errors if its monkeypatched to
            # the call method, so we must override fanout to False
            if 'fanout' in kwargs:
                kwargs['fanout'] = False
            cctxt = orig_prepare(self, *args, **kwargs)
            CastAsCall._stub_out(stubs, cctxt)  # woo, recurse!
            return cctxt

        stubs.Set(obj, 'prepare', prepare)
        stubs.Set(obj, 'cast', obj.call)
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/tests/unit/cast_as_call.py/CastAsCall._stub_out/original