treebeardtech / nbmake

📝 Pytest plugin for testing notebooks
https://pypi.org/project/nbmake/
Apache License 2.0
179 stars 18 forks source link

Pytest 8.1.0 compatibility #119

Closed anilbey closed 5 months ago

anilbey commented 5 months ago

Hi,

I think an update is required in to be compatible with Pytest 8.1.0. Source (CI logs of a project): https://github.com/BlueBrain/BlueCelluLab/actions/runs/8138274377/job/22239014458?pr=142 The packages installed as well as the environment can be found on the CI logs.

     File "/home/runner/work/BlueCelluLab/BlueCelluLab/.tox/examples/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1490, in parse
      self._preparse(args, addopts=addopts)
    File "/home/runner/work/BlueCelluLab/BlueCelluLab/.tox/examples/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1377, in _preparse
      self.pluginmanager.load_setuptools_entrypoints("pytest11")
    File "/home/runner/work/BlueCelluLab/BlueCelluLab/.tox/examples/lib/python3.11/site-packages/pluggy/_manager.py", line 415, in load_setuptools_entrypoints
      self.register(plugin, name=ep.name)
    File "/home/runner/work/BlueCelluLab/BlueCelluLab/.tox/examples/lib/python3.11/site-packages/_pytest/config/__init__.py", line 497, in register
      plugin_name = super().register(plugin, name)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/runner/work/BlueCelluLab/BlueCelluLab/.tox/examples/lib/python3.11/site-packages/pluggy/_manager.py", line 167, in register
      self._verify_hook(hook, hookimpl)
    File "/home/runner/work/BlueCelluLab/BlueCelluLab/.tox/examples/lib/python3.11/site-packages/pluggy/_manager.py", line 342, in _verify_hook
      raise PluginValidationError(
  pluggy._manager.PluginValidationError: Plugin 'nbmake' for hook 'pytest_collect_file'
  hookimpl definition: pytest_collect_file(path: str, parent: Any) -> Optional[Any]
  Argument(s) {'path'} are declared in the hookimpl but can not be found in the hookspec

Related discussion on pytest: https://github.com/pytest-dev/pytest/issues/12065#issuecomment-1976275219

alex-treebeard commented 5 months ago

Thanks for this report! I sense this is disruptive so am looking into it ASAP.

In the meantime, it would be really awesome if you joined our new Discord. Communities can help prevent issues like as well as identify new helpful things to build for you.

https://discord.gg/QFjCpMjqRY

alex-treebeard commented 5 months ago

So it appears that the path parameter to collect has now been removed in favour of a file_path which uses the Pathlib type.

Relevant github issue

I'd like to fix this in a way that keeps support for Pytest 7 although simplest thing to do would be to support >8 going forward. Open to suggestions.

ManonMarchand commented 5 months ago

What about something that detects the major version of pytest?

alex-treebeard commented 5 months ago

@ManonMarchand thanks that's what I did -- it should work the same for pytest 6 and 7

Fixed in release v1.5.1

anilbey commented 5 months ago

Thanks @alex-treebeard for the quick fix.

anilbey commented 5 months ago

It appears pytest 8.1.0 is yanked. https://pypi.org/project/pytest/8.1.0/

alex-treebeard commented 5 months ago

😄 I did feel like there was no warning about this change... we are ok though as far as I know, apart from the dev environment for nbmake being on 8.1