Skip to content

pytest 8.1.0 breaks nbval 0.10.0 #202

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

Closed
ryan-williams opened this issue Mar 3, 2024 · 1 comment · Fixed by #203
Closed

pytest 8.1.0 breaks nbval 0.10.0 #202

ryan-williams opened this issue Mar 3, 2024 · 1 comment · Fixed by #203

Comments

@ryan-williams
Copy link

Seems that pytest 8.1.0 (just released) breaks nbval 0.10.0:

alias test="docker run --rm python:3.11.8 /bin/bash -c"
test "pip install nbval         pytest        && pytest --nbval"  # ❌ PluginValidationError: Argument(s) {'path'} are declared in the hookimpl but can not be found in the hookspec
test "pip install nbval==0.10.0 pytest==8.1.0 && pytest --nbval"  # ❌ same as above
test "pip install nbval==0.10.0 pytest==8.0.2 && pytest --nbval"  # ✅ ok with pytest<8.1

See pytest-dev/pytest#11779 (comment):

As part of the py.path -> pathlib.Path transition, the py.path hook parameters have been deprecated in the 7.x series, changed to an error in 8.0, and finally removed in 8.1. It seems like the pytest_ignore_collect hook implementation in the pytest_filter_subpackage plugin still uses the deprecated path argument, should use collection_path instead (available since pytest 7.0.0).

If you can require pytest>=7, then can just replace path -> collection_path (and possibly adjust for py.path.local -> Path).

Example error output:

Traceback (most recent call last):
  File "/usr/local/bin/pytest", line 8, in <module>
    sys.exit(console_main())
             ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 195, in console_main
    code = main()
           ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 153, in main
    config = _prepareconfig(args, plugins)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 335, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_hooks.py", line 501, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 119, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 138, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 121, in _multicall
    teardown.throw(exception)  # type: ignore[union-attr]
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/_pytest/helpconfig.py", line 105, in pytest_cmdline_parse
    config = yield
             ^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 102, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1141, in pytest_cmdline_parse
    self.parse(args)
  File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1490, in parse
    self._preparse(args, addopts=addopts)
  File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1377, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 415, in load_setuptools_entrypoints
    self.register(plugin, name=ep.name)
  File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 497, in register
    plugin_name = super().register(plugin, name)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 167, in register
    self._verify_hook(hook, hookimpl)
  File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 342, in _verify_hook
    raise PluginValidationError(
pluggy._manager.PluginValidationError: Plugin 'nbval' for hook 'pytest_collect_file'
hookimpl definition: pytest_collect_file(path, parent)
Argument(s) {'path'} are declared in the hookimpl but can not be found in the hookspec
@takluyver
Copy link
Member

Thanks! I think it's reasonable to require pytest >= 7 now; I've opened #203 to do this.

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

Successfully merging a pull request may close this issue.

2 participants