Skip to content

Commit

Permalink
Merge pull request #152 from takluyver/from-parent
Browse files Browse the repository at this point in the history
Use new Node.from_parent constructor when available
  • Loading branch information
vidartf committed Jul 30, 2020
2 parents 3597e0b + f2ce5e7 commit bf53ad9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions nbval/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ def pytest_collect_file(path, parent):
"""
opt = parent.config.option
if (opt.nbval or opt.nbval_lax) and path.fnmatch("*.ipynb"):
return IPyNbFile(path, parent)
# 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)
else: # Pytest < 5.4
return IPyNbFile(path, parent)



Expand Down Expand Up @@ -308,8 +312,14 @@ def collect(self):
)
options.update(comment_opts)
options.setdefault('check', self.compare_outputs)
yield IPyNbCell('Cell ' + str(cell_num), self, cell_num,
cell, options)
name = 'Cell ' + str(cell_num)
# https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent
if hasattr(IPyNbCell, "from_parent"):
yield IPyNbCell.from_parent(
self, name=name, cell_num=cell_num, cell=cell, options=options
)
else:
yield IPyNbCell(name, self, cell_num, cell, options)

# Update 'code' cell count
cell_num += 1
Expand Down

0 comments on commit bf53ad9

Please sign in to comment.