如何使用 python mock来消除方法装饰器的行为,以便我不依赖它们来测试当前方法?
import utils
class Router(object):
@utils.with_user
@utils.formatted_response('resources', with_pagination=True)
def get_resources(self, user_id=None, offset=None, limit=None):
# do stuff
pass
我已经尝试过:
# @patch('utils.with_tenant')
# @patch.object(utils, 'with_tenant')
def test_stub_decorator(self):
# patch('utils.with_tenant')
# patch.object(utils, 'with_tenant')
这些似乎都不起作用!有任何想法吗?