接口测试 最近在学习接口测试,使用 pycharm 运行用例时报错" AttributeError: 'TestCaseFunction' object has no attribute 'get_closest_marker' ",求指点

左撇子的菜鸟 · 2019年08月26日 · 最后由 左撇子的菜鸟 回复于 2019年08月29日 · 2715 次阅读

代码如下:

报错信息:
platform win32 -- Python 3.7.3, pytest-3.0.7, py-1.8.0, pluggy-0.4.0
rootdir: D:\Python\test\uu, inifile:
plugins: ordering-0.6
collected 1 itemsINTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages_pytest\main.py", line 98, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages_pytest\main.py", line 132, in main
INTERNALERROR> config.hook.pytest_collection(session=session)
INTERNALERROR> File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages_pytest\vendored_packages\pluggy.py", line 745, in __call
_
INTERNALERROR> return self.hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR> File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages_pytest\vendored_packages\pluggy.py", line 339, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages_pytest\vendored_packages\pluggy.py", line 334, in
INTERNALERROR> _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR> File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages_pytest\vendored_packages\pluggy.py", line 614, in execute
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages_pytest\main.py", line 141, in pytest_collection
INTERNALERROR> return session.perform_collect()
INTERNALERROR> File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages_pytest\main.py", line 602, in perform_collect
INTERNALERROR> config=self.config, items=items)
INTERNALERROR> File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages_pytest\vendored_packages\pluggy.py", line 745, in __call
_
INTERNALERROR> return self.hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR> File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages_pytest\vendored_packages\pluggy.py", line 339, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages_pytest\vendored_packages\pluggy.py", line 334, in
INTERNALERROR> _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR> File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages_pytest\vendored_packages\pluggy.py", line 614, in execute
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "C:\Python37\lib\site-packages\pytest_ordering__init
_.py", line 45, in pytest_collection_modifyitems
INTERNALERROR> mark = item.get_closest_marker(mark_name)
INTERNALERROR> AttributeError: 'TestCaseFunction' object has no attribute 'get_closest_marker'
请大神们指点下

共收到 5 条回复 时间 点赞


建议楼主多看看 requests 的文档,post 请求里面是 data,不是 params,你如果是请求获取 url 的参数的话应该是 get 请求吧,试试换这个请求方式,另外可以对比 postman 上面的请求结果,是否要传 header 之类的

请问下-> None 什么意思 我每次都删掉了

删掉 None

Wensau 回复

跟 none 关系,已经解决了,是 pytest 的版本问题,开始用的版本是最新的,降成 3.10.0 就能正常使用了

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册