7

我维护了一个开源库xarray,它使用 pytest 在 Travis-CI 上运行集成测试。我们使用堆栈 conda 安装科学 Python。

今天早些时候,我们的五个测试版本中有两个(Python 3.5 和 3.6,但不是 Python 2.7 或 3.4)开始无缘无故地失败。pytest 本身失败了,带有一个神秘的引用:

$ py.test xarray --cov=xarray --cov-config ci/.coveragerc --cov-report term-missing --verbose $EXTRA_FLAGS
Traceback (most recent call last):
  File "/home/travis/miniconda/envs/test_env/bin/py.test", line 6, in <module>
    sys.exit(py.test.main())
  File "/home/travis/miniconda/envs/test_env/lib/python3.6/site-packages/_pytest/config.py", line 49, in main
    config = _prepareconfig(args, plugins)
  File "/home/travis/miniconda/envs/test_env/lib/python3.6/site-packages/_pytest/config.py", line 168, in _prepareconfig
    pluginmanager=pluginmanager, args=args)
  File "/home/travis/miniconda/envs/test_env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/home/travis/miniconda/envs/test_env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/travis/miniconda/envs/test_env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/home/travis/miniconda/envs/test_env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
  File "/home/travis/miniconda/envs/test_env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 250, in _wrapped_call
    wrap_controller.send(call_outcome)
  File "/home/travis/miniconda/envs/test_env/lib/python3.6/site-packages/_pytest/helpconfig.py", line 68, in pytest_cmdline_parse
    config = outcome.get_result()
  File "/home/travis/miniconda/envs/test_env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/travis/miniconda/envs/test_env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
    self.result = func()
  File "/home/travis/miniconda/envs/test_env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
    res = hook_impl.function(*args)
  File "/home/travis/miniconda/envs/test_env/lib/python3.6/site-packages/_pytest/config.py", line 957, in pytest_cmdline_parse
    self.parse(args)
  File "/home/travis/miniconda/envs/test_env/lib/python3.6/site-packages/_pytest/config.py", line 1121, in parse
    self._preparse(args, addopts=addopts)
  File "/home/travis/miniconda/envs/test_env/lib/python3.6/site-packages/_pytest/config.py", line 1084, in _preparse
    self.pluginmanager.load_setuptools_entrypoints('pytest11')
  File "/home/travis/miniconda/envs/test_env/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py", line 510, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/home/travis/miniconda/envs/test_env/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2409, in load
    return self.resolve()
  File "/home/travis/miniconda/envs/test_env/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2415, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
ModuleNotFoundError: No module named 'hypothesis.extra.pytestplugin'

关于这件事,有几件事让我感到惊讶:

  1. 我们不使用假设或安装hypothesis.extra.pytestplugin。我不知道这是从哪里来的。
  2. 没有什么明显的变化会触发此错误。它首先出现在一行 doc change之后。安装的 Python 库,包括 conda 安装的特定二进制构建,似乎完全相同。(不过,如果您愿意,您可以diff自己构建输出。)

如果您对发生的事情有任何线索或猜测,我们将不胜感激!我什至不知道在堆栈中的哪个位置提交错误。

4

1 回答 1

2

我对此进行了一些研究:

  • Conda forge 为我们提供hypothesis: 3.33.0-py36_0并将pytest其作为插件加载
  • 将 conda 版本固定为hypothesis3.23纠正问题。
  • 卸载假设解决了问题
  • pip安装假设解决问题

所以,我认为我们可以得出结论,假设的 conda-forge 构建出了问题。

页面上有一个未解决的问题conda-forge

https://github.com/conda-forge/hypothesis-feedstock/issues/16

于 2017-10-25T16:58:24.833 回答