我在Django代码库中频繁使用以下通用的装饰器调用:
@override_settings(
CACHES={
**settings.CACHES,
"default": generate_cache("default", dummy=False),
"throttling": generate_cache("throttling", dummy=False),
}
)
def test_something():
...
装饰器代码太冗长了,我希望将这段代码封装成一个新的装饰器@use_real_cache
,这样测试函数看起来会更清晰:
@use_real_cache
def test_something():
...
我该如何使用另一个装饰器包裹装饰器?