diff --git a/pkgs/development/python-modules/pytest-notebook/default.nix b/pkgs/development/python-modules/pytest-notebook/default.nix index 6d24c8c2ac60..5273c7540626 100644 --- a/pkgs/development/python-modules/pytest-notebook/default.nix +++ b/pkgs/development/python-modules/pytest-notebook/default.nix @@ -38,6 +38,11 @@ buildPythonPackage rec { hash = "sha256-LoK0wb7rAbVbgyURCbSfckWvJDef3tPY+7V4YU1IBRU="; }; + patches = [ + # Rename pytest_collect_file hook parameter `path` -> `file_path` for pytest 9. + ./pytest9-collect-hook.patch + ]; + postPatch = '' # we disable the tests relying on coverage for unrelated reasons substituteInPlace tests/test_execution.py \ diff --git a/pkgs/development/python-modules/pytest-notebook/pytest9-collect-hook.patch b/pkgs/development/python-modules/pytest-notebook/pytest9-collect-hook.patch new file mode 100644 index 000000000000..c35a77dd6159 --- /dev/null +++ b/pkgs/development/python-modules/pytest-notebook/pytest9-collect-hook.patch @@ -0,0 +1,31 @@ +--- a/pytest_notebook/plugin.py ++++ b/pytest_notebook/plugin.py +@@ -11,6 +11,7 @@ + + """ + import os ++from fnmatch import fnmatch + import shlex + + import pytest +@@ -263,16 +264,16 @@ + return NBRegressionFixture(**kwargs) + + +-def pytest_collect_file(path, parent): ++def pytest_collect_file(file_path, parent): + """Collect Jupyter notebooks using the specified pytest hook.""" + kwargs, other_args = gather_config_options(parent.config) + if other_args.get("nb_test_files", False) and any( +- path.fnmatch(pat) for pat in other_args.get("nb_file_fnmatch", ["*.ipynb"]) ++ fnmatch(file_path.name, pat) for pat in other_args.get("nb_file_fnmatch", ["*.ipynb"]) + ): + try: +- return JupyterNbCollector.from_parent(parent, fspath=path) ++ return JupyterNbCollector.from_parent(parent, path=file_path) + except AttributeError: +- return JupyterNbCollector(path, parent) ++ return JupyterNbCollector(file_path, parent) + + + class JupyterNbCollector(pytest.File):