Skip to content

Commit 76e052a

Browse files
committed
Switch collection hook to use pathlib paths
1 parent d7bc348 commit 76e052a

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

nbval/plugin.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,21 +134,14 @@ def pytest_configure(config):
134134

135135

136136

137-
def pytest_collect_file(path, parent):
137+
def pytest_collect_file(collection_path, parent):
138138
"""
139139
Collect IPython notebooks using the specified pytest hook
140140
"""
141141
opt = parent.config.option
142-
if (opt.nbval or opt.nbval_lax) and path.fnmatch("*.ipynb"):
142+
if (opt.nbval or opt.nbval_lax) and collection_path.suffix == ".ipynb":
143143
# https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent
144-
if hasattr(IPyNbFile, "from_parent"):
145-
try: # Pytest >= 7.0.0
146-
return IPyNbFile.from_parent(parent, path=Path(path))
147-
except AssertionError:
148-
return IPyNbFile.from_parent(parent, fspath=path)
149-
else: # Pytest < 5.4
150-
return IPyNbFile(path, parent)
151-
144+
return IPyNbFile.from_parent(parent, path=collection_path)
152145

153146

154147
comment_markers = {

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
]
2222
},
2323
install_requires = [
24-
'pytest >= 2.8',
24+
'pytest >= 7',
2525
'jupyter_client',
2626
'nbformat',
2727
'ipykernel',

0 commit comments

Comments
 (0)