@@ -112,7 +112,11 @@ def pytest_collect_file(path, parent):
112
112
"""
113
113
opt = parent .config .option
114
114
if (opt .nbval or opt .nbval_lax ) and path .fnmatch ("*.ipynb" ):
115
- return IPyNbFile (path , parent )
115
+ # https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent
116
+ if hasattr (IPyNbFile , "from_parent" ):
117
+ return IPyNbFile .from_parent (parent , fspath = path )
118
+ else : # Pytest < 5.4
119
+ return IPyNbFile (path , parent )
116
120
117
121
118
122
@@ -308,8 +312,14 @@ def collect(self):
308
312
)
309
313
options .update (comment_opts )
310
314
options .setdefault ('check' , self .compare_outputs )
311
- yield IPyNbCell ('Cell ' + str (cell_num ), self , cell_num ,
312
- cell , options )
315
+ name = 'Cell ' + str (cell_num )
316
+ # https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent
317
+ if hasattr (IPyNbCell , "from_parent" ):
318
+ yield IPyNbCell .from_parent (
319
+ self , name = name , cell_num = cell_num , cell = cell , options = options
320
+ )
321
+ else :
322
+ yield IPyNbCell (name , self , cell_num , cell , options )
313
323
314
324
# Update 'code' cell count
315
325
cell_num += 1
0 commit comments