python 使用装饰器提示:TypeError: wrapper() takes no arguments (1 given)
2017-01-10 14:02
806 查看
使用装饰器,在每条用例之前需要对手机清log
tool.py def LogClear(fn): def wrapper(): os.system("adb logcat -c") print 'logclear' fn() return wrapper
Calc.py class Calc(unittest.TestCase): @LogClear def test_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.pydef LogClear(fn):def wrapper(self):os.system("adb logcat -c")print 'logclear'fn(self)return wrapper
相关文章推荐
- type error:this constructor takes no arguments的错误提示(python)
- TypeError: this constructor takes no arguments(Python 学习遇到的错误1)
- Python技术相关的bottle框架自带服务器例子脚本提示takes no arguments 1 given 错误
- python之TypeError: this constructor takes no arguments
- Python 3.5 + PyInstaller 3.2.1打包exe出错,TypeError: read() takes no keyword arguments
- python:TypeError: this constructor takes no arguments解决方法
- python "TypeError: object() takes no parameters"
- 在Python中TypeError: object() takes no parameters新手问题的解决办法
- python3中遇到的一个bug TypeError: is_empty() takes 0 positional arguments but 1 was given
- python3使用pickle读取文件提示TypeError或者UnicodeDecodeError的解决办法
- python3使用pickle读取文件提示TypeError或者UnicodeDecodeError的解决办法
- 使用ajaxfileupload插件提示Uncaught TypeError:has no method 'handleError'
- TypeError: this constructor takes no arguments
- Python_TypeError:object() takes no parameters
- python报错 TypeError: object() takes no parameters
- python 提示错误AttributeError: type object 'str' has no attribute '_name_'
- Python3问题TypeError: object() takes no parameters
- python机器学习实战3.2提示错误AttributeError: type object 'str' has no attribute '_name_'
- python安装pbkdf2 遇到错误TypeError: __call__() takes exactly 2 arguments (1 given)
- python3使用pickle读取文件提示TypeError或者UnicodeDecodeError的解决办法