解决报错:unknown hook ‘pytest_namespace‘ in plugin

右键运行pytest run时报错,原因是pytest版本过高导致的。有时候会遇到在自己本机没问题,拉取服务器代码下来后就出问题了,所以把pytest版本改低就可以,亲测有效,希望对你有帮助

完整报错信息:

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "E:\Program Files\Develop\Python37\lib\site-packages\_pytest\main.py", line 191, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "E:\Program Files\Develop\Python37\lib\site-packages\_pytest\main.py", line 234, in _main
INTERNALERROR>     config.hook.pytest_collection(session=session)
INTERNALERROR>   File "E:\Program Files\Develop\Python37\lib\site-packages\pluggy\hooks.py", line 289, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "E:\Program Files\Develop\Python37\lib\site-packages\pluggy\manager.py", line 87, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "E:\Program Files\Develop\Python37\lib\site-packages\pluggy\manager.py", line 81, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "E:\Program Files\Develop\Python37\lib\site-packages\pluggy\callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "E:\Program Files\Develop\Python37\lib\site-packages\pluggy\callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "E:\Program Files\Develop\Python37\lib\site-packages\pluggy\callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "E:\Program Files\Develop\Python37\lib\site-packages\_pytest\main.py", line 244, in pytest_collection
INTERNALERROR>     return session.perform_collect()
INTERNALERROR>   File "E:\Program Files\Develop\Python37\lib\site-packages\_pytest\main.py", line 438, in perform_collect
INTERNALERROR>     self.config.pluginmanager.check_pending()
INTERNALERROR>   File "E:\Program Files\Develop\Python37\lib\site-packages\pluggy\manager.py", line 270, in check_pending
INTERNALERROR>     % (name, hookimpl.plugin),
INTERNALERROR> pluggy.manager.PluginValidationError: unknown hook 'pytest_namespace' in plugin <module 'allure.pytest_plugin' from 'E:\\Program Files\\Develop\\Python37\\lib\\site-packages\\allure\\pytest_plugin.py'>

检查自己的pytest版本为: pytest                5.1.2

卸载已有的pytest

pip uninstall pytest

指定安装pytest4.0.2版本:

pip install pytest==4.0.2

安装成功后,再次运行成功

============================= test session starts =============================
platform win32 -- Python 3.7.4, pytest-4.0.2, py-1.8.0, pluggy-0.12.0 -- E:\Program Files\Develop\Python37\python.exe
cachedir: .pytest_cache
rootdir: D:\workresource\PythonProject\Python_API\tests, inifile:
plugins: allure-adaptor-1.7.10
collecting ... collected 1 item

test_API.py::TestRun::test_YLMY_login PASSED                             [100%]

========================== 1 passed in 0.11 seconds ===========================

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值