Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'call_runtest_hook' from '_pytest.runner' #12066

Closed
3 of 4 tasks
shreyasvinaya opened this issue Mar 4, 2024 · 3 comments
Closed
3 of 4 tasks

Comments

@shreyasvinaya
Copy link

Hi while running pytest on github CI, i got the below error:
ImportError: cannot import name 'call_runtest_hook' from '_pytest.runner'

here is the full trace:

Traceback (most recent call last):
  File "/home/runner/miniconda3/envs/deepchem/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "/home/runner/miniconda3/envs/deepchem/lib/python3.9/site-packages/_pytest/config/__init__.py", line 195, in console_main
    code = main()
  File "/home/runner/miniconda3/envs/deepchem/lib/python3.9/site-packages/_pytest/config/__init__.py", line 153, in main
    config = _prepareconfig(args, plugins)
  File "/home/runner/miniconda3/envs/deepchem/lib/python3.9/site-packages/_pytest/config/__init__.py", line 335, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
  File "/home/runner/miniconda3/envs/deepchem/lib/python3.9/site-packages/pluggy/_hooks.py", line 501, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "/home/runner/miniconda3/envs/deepchem/lib/python3.9/site-packages/pluggy/_manager.py", line 119, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/home/runner/miniconda3/envs/deepchem/lib/python3.9/site-packages/pluggy/_callers.py", line 138, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/home/runner/miniconda3/envs/deepchem/lib/python3.9/site-packages/pluggy/_callers.py", line 121, in _multicall
    teardown.throw(exception)  # type: ignore[union-attr]
  File "/home/runner/miniconda3/envs/deepchem/lib/python3.9/site-packages/_pytest/helpconfig.py", line 105, in pytest_cmdline_parse
    config = yield
  File "/home/runner/miniconda3/envs/deepchem/lib/python3.9/site-packages/pluggy/_callers.py", line 102, in _multicall
    res = hook_impl.function(*args)
  File "/home/runner/miniconda3/envs/deepchem/lib/python3.9/site-packages/_pytest/config/__init__.py", line 1141, in pytest_cmdline_parse
    self.parse(args)
  File "/home/runner/miniconda3/envs/deepchem/lib/python3.9/site-packages/_pytest/config/__init__.py", line 1490, in parse
    self._preparse(args, addopts=addopts)
  File "/home/runner/miniconda3/envs/deepchem/lib/python3.9/site-packages/_pytest/config/__init__.py", line 1377, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/home/runner/miniconda3/envs/deepchem/lib/python3.9/site-packages/pluggy/_manager.py", line 414, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/home/runner/miniconda3/envs/deepchem/lib/python3.9/importlib/metadata.py", line 86, in load
    module = import_module(match.group('module'))
  File "/home/runner/miniconda3/envs/deepchem/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "/home/runner/miniconda3/envs/deepchem/lib/python3.9/site-packages/_pytest/assertion/rewrite.py", line 178, in exec_module
    exec(co, module.__dict__)
  File "/home/runner/miniconda3/envs/deepchem/lib/python3.9/site-packages/flaky/flaky_pytest_plugin.py", line 5, in <module>
    from _pytest.runner import call_runtest_hook  # pylint:disable=import-error
ImportError: cannot import name 'call_runtest_hook' from '_pytest.runner' (/home/runner/miniconda3/envs/deepchem/lib/python3.9/site-packages/_pytest/runner.py)

Requesting you to please help me fix the bug

System specifications:
OS: Ubuntu 22.04
python version: 3.8, 3.9, 3.10, 3.11
pytest version: 8.1.0
command used: pytest -v -m 'jax' deepchem

  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible
@bluetech
Copy link
Member

bluetech commented Mar 4, 2024

The error happens in the flaky plugin, it uses some private pytest code that has changed in pytest 8.1, so unfortunately it will need to be updated to be compatible with pytest 8.1. Please report the issue to flaky.

@bluetech bluetech closed this as completed Mar 4, 2024
@The-Compiler
Copy link
Member

Already reported here: box/flaky#198

But given that flaky hasn't had a release since 2020 and hasn't had a commit for the past half year (with nobody seeming to care), you're probably better off to migrating to something that's actually maintained (e.g. pytest-rerunfailures).

@SvenStaehs
Copy link

to sum up the current state for future readers:
flaky has released 3.8.1, which fixes the issue.

@The-Compiler's suggestion is valid nevertheless, flaky doesn't seem to be actively developed so especially new users should consider a different option. But it's good to see that serious issues are addressed for us existing users, I wanna acknowledge that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants