pytest基本示例失败并出现配置错误

时间:2019-02-20 19:07:04

标签: python pytest

我已经创建了此处描述的基本示例:https://docs.pytest.org/en/latest/index.html

但是当我输入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'

有什么建议吗?

3 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

好吧,您的错误提示该软件包只能在git repo中使用。您启动了git repo吗?

答案 2 :(得分:0)

我猜想这与您已安装的pytest和pytest-benchmark版本不兼容。使用pip install pytest-benchmark从pip安装两个文件对我来说解决了类似的问题。