Python Pytest基本示例因配置错误而失败

Python Pytest基本示例因配置错误而失败,python,pytest,Python,Pytest,我创建了下面描述的基本示例: 但是当我键入pytest时,我得到 INTERNALERROR> Traceback (most recent call last): INTERNALERROR> File "/Users/alberto/Documents/FIREDRAKE/firedrake/lib/python3.7/site-packages/_pytest/main.py", line 206, in wrap_session INTERNALERROR>

我创建了下面描述的基本示例:

但是当我键入
pytest
时,我得到

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/alberto/Documents/FIREDRAKE/firedrake/lib/python3.7/site-packages/_pytest/main.py", line 206, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>   File "/Users/alberto/Documents/FIREDRAKE/firedrake/lib/python3.7/site-packages/_pytest/config/__init__.py", line 639, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>   File "/Users/alberto/Documents/FIREDRAKE/firedrake/lib/python3.7/site-packages/pluggy/hooks.py", line 306, in call_historic
INTERNALERROR>     res = self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/Users/alberto/Documents/FIREDRAKE/firedrake/lib/python3.7/site-packages/pluggy/manager.py", line 67, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/Users/alberto/Documents/FIREDRAKE/firedrake/lib/python3.7/site-packages/pluggy/manager.py", line 61, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "/Users/alberto/Documents/FIREDRAKE/firedrake/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/alberto/Documents/FIREDRAKE/firedrake/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/alberto/Documents/FIREDRAKE/firedrake/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/alberto/Documents/FIREDRAKE/firedrake/lib/python3.7/site-packages/pytest_benchmark/plugin.py", line 427, in pytest_configure
INTERNALERROR>     bs = config._benchmarksession = BenchmarkSession(config)
INTERNALERROR>   File "/Users/alberto/Documents/FIREDRAKE/firedrake/lib/python3.7/site-packages/pytest_benchmark/session.py", line 31, in __init__
INTERNALERROR>     self.logger = Logger(self.verbose, config)
INTERNALERROR>   File "/Users/alberto/Documents/FIREDRAKE/firedrake/lib/python3.7/site-packages/pytest_benchmark/logger.py", line 15, in __init__
INTERNALERROR>     self.pytest_warn = config.warn
INTERNALERROR> AttributeError: 'Config' object has no attribute 'warn'

INTERNALERROR>Traceback(最近一次调用):
内部错误>文件“/Users/alberto/Documents/FIREDRAKE/FIREDRAKE/lib/python3.7/site packages/_pytest/main.py”,第206行,在wrap_会话中
INTERNALERROR>config.\u do\u configure()
INTERNALERROR>File“/Users/alberto/Documents/FIREDRAKE/FIREDRAKE/lib/python3.7/site-packages/\u-pytest/config/\uuuuuuuuuu-init\uuuuuuuuuuu.py”,第639行,在配置中
INTERNALERROR>self.hook.pytest\u configure.call\u historic(kwargs=dict(config=self))
内部错误>文件“/Users/alberto/Documents/FIREDRAKE/FIREDRAKE/lib/python3.7/site-packages/pluggy/hooks.py”,第306行,在call_中
INTERNALERROR>res=self.\u hookexec(self,self.get\u hookimpls(),kwargs)
内部错误>文件“/Users/alberto/Documents/FIREDRAKE/FIREDRAKE/lib/python3.7/site packages/pluggy/manager.py”,第67行,在
内部错误>返回自我。\u内部\u hookexec(钩子、方法、kwargs)
内部错误>文件“/Users/alberto/Documents/FIREDRAKE/FIREDRAKE/lib/python3.7/site packages/pluggy/manager.py”,第61行,在
INTERNALERROR>firstresult=hook.spec.opts.get(“firstresult”)如果hook.spec else为False,
内部错误>文件“/Users/alberto/Documents/FIREDRAKE/FIREDRAKE/lib/python3.7/site packages/pluggy/callers.py”,第208行,在多调用中
INTERNALERROR>返回结果。获取结果()
内部错误>文件“/Users/alberto/Documents/FIREDRAKE/FIREDRAKE/lib/python3.7/site packages/pluggy/callers.py”,第80行,在get_结果中
INTERNALERROR>raise ex[1]。使用_回溯(ex[2])
内部错误>文件“/Users/alberto/Documents/FIREDRAKE/FIREDRAKE/lib/python3.7/site packages/pluggy/callers.py”,第187行,在多调用中
INTERNALERROR>res=hook_impl.function(*args)
内部错误>文件“/Users/alberto/Documents/FIREDRAKE/FIREDRAKE/lib/python3.7/site packages/pytest\u benchmark/plugin.py”,第427行,在pytest\u配置中
INTERNALERROR>bs=config.\u benchmarksession=benchmarksession(配置)
内部错误>文件“/Users/alberto/Documents/FIREDRAKE/FIREDRAKE/lib/python3.7/site packages/pytest\u benchmark/session.py”,第31行,在__
INTERNALERROR>self.logger=logger(self.verbose,配置)
内部错误>文件“/Users/alberto/Documents/FIREDRAKE/FIREDRAKE/lib/python3.7/site packages/pytest\u benchmark/logger.py”,第15行,在__
INTERNALERROR>self.pytest\u warn=config.warn
INTERNALERROR>AttributeError:“配置”对象没有属性“警告”

有什么建议吗?

嗯,您的错误是该包只能在git回购中使用。你启动了git回购吗?

我想这是因为你安装的pytest和pytest基准版本不兼容。使用
pip安装pytest benchmark从pip安装这两个版本
修复了一个类似的问题。

如果您使用的是python3,则可以使用pip3来管理软件包。因为实际上,我在使用pip的python2.7上的包之间出现错误,一些包没有更新,所以您可以选择一些安全版本来设置,例如(pytest==3.9.3)。可能您安装的版本在该特定类中没有“警告”功能。实际上,我正在使用unittest包来运行和构建测试用例,如果您需要速度,您可以尝试这种方法,或者修复那些依赖性问题以使用pytest运行

我在git存储库中得到了完全相同的错误。错误消息中的第一行出现只是因为我重新创建了基本示例。我现在删除了错误消息中的第一行,因为它具有误导性。它似乎没有正确配置。您确定您的pytest版本与python3.7兼容吗?您可能需要更新相同的错误会在
pip安装pytest--upgrade
之后出现。我在conda forge安装pytest和pytest基准时出现了此错误。当我卸载pytest基准测试时,错误就消失了。这似乎是。我没有用康达