python3Packages.pytest-notebook: fix build with pytest 9

This commit is contained in:
Harinn
2026-05-25 19:47:39 +07:00
parent 2bb5ecd583
commit 81a7ca2c6d
2 changed files with 36 additions and 0 deletions
@@ -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 \
@@ -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):