Skip to content

Commit 184d364

Browse files
authored
Merge pull request #191 from pgbarletta/fix-warn
Fixed PytestRemovedIn8Warning.
2 parents f48c660 + 3f9dd52 commit 184d364

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

nbval/plugin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import hashlib
1616
import warnings
1717
from collections import OrderedDict, defaultdict
18+
from pathlib import Path
1819

1920
from queue import Empty
2021

@@ -141,7 +142,10 @@ def pytest_collect_file(path, parent):
141142
if (opt.nbval or opt.nbval_lax) and path.fnmatch("*.ipynb"):
142143
# https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent
143144
if hasattr(IPyNbFile, "from_parent"):
144-
return IPyNbFile.from_parent(parent, fspath=path)
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)
145149
else: # Pytest < 5.4
146150
return IPyNbFile(path, parent)
147151

0 commit comments

Comments
 (0)