【发布时间】:2019-05-15 11:32:49
【问题描述】:
def acquisition_required(method):
def wrapped_method(self, *args, **kwargs):
result=some complex code
if not result:
some code is here
else:
return method(self, *args, **kwargs)
return wrapped_method
我想为此编写一个单元测试 例如。
assertEqual, assertTrue..
但我不知道如何测试它我已经对返回一些值或真/假的函数进行了单元测试。
我不想要任何代码只是概念
【问题讨论】:
-
你用同样的方法来做:你调用装饰器返回的方法,并验证它是否产生了预期的值。
-
@tobias_k 我做了一些更正,现在可以了
标签: python unit-testing