Skip to content

Commit

Permalink
fix pytest>=7.0.0 error
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Feb 27, 2022
1 parent 6dd2eaa commit df89086
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nbval/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import warnings
from collections import OrderedDict, defaultdict

from pathlib import Path
from queue import Empty

# for reading notebook files
Expand Down Expand Up @@ -141,7 +142,10 @@ def pytest_collect_file(path, parent):
if (opt.nbval or opt.nbval_lax) and path.fnmatch("*.ipynb"):
# https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent
if hasattr(IPyNbFile, "from_parent"):
return IPyNbFile.from_parent(parent, fspath=path)
try:
return IPyNbFile.from_parent(parent, path=Path(path))
except Exception: # Pytest < 7.0
return IPyNbFile.from_parent(parent, fspath=path)
else: # Pytest < 5.4
return IPyNbFile(path, parent)

Expand Down

0 comments on commit df89086

Please sign in to comment.