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

grep · August 26, 2019 · Last by grep replied at August 29, 2019 · 922 hits

代码如下:

报错信息:
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

grep #5 · August 29, 2019 作者
Wensau 回复

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

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up