python 装饰器提示(TypeError: wrapper() takes no arguments (1 given))
上一篇 /
下一篇 2017-01-10 13:33:13
/ 个人分类:python
使用
装饰器,在每条用例之前需要对
手机清log
tool.py defLogClear(fn): defwrapper(): os.system("adb logcat -c") print'logclear' fn() returnwrapper |
Calc.py classCalc(unittest.TestCase): @LogClear deftest_calc(self): self.driver.start_activity('com.google.android.calculator','com.android.calculator2.Calculator') self.driver.find_element_by_id("com.google.android.calculator:id/digit_4").click() res =self.driver.find_element_by_id("com.google.android.calculator:id/formula").text AssertAct(self, res,'5','the result of calc is not correct',get_mod()) |
执行,提示:TypeError: wrapper() takes no arguments (1 given)
其实要添加在装饰器上添加一个参数:
tool.pydefLogClear(fn): defwrapper(self): os.system("adb logcat -c") print'logclear' fn(self) returnwrapper
|
收藏
举报
TAG:
Python
python
装饰器