1212from packaging .version import Version
1313
1414
15- def pytest_collect_file (parent , path ):
16- if path . ext == ".ipynb" :
17- return NotebookFile .from_parent (parent , fspath = path )
15+ def pytest_collect_file (parent , file_path ):
16+ if file_path . suffix == ".ipynb" :
17+ return NotebookFile .from_parent (parent , path = file_path )
1818
1919
2020class NotebookFile (pytest .File ):
2121 if Version (pytest .__version__ ) < Version ("5.4.0" ):
2222
2323 @classmethod
24- def from_parent (cls , parent , fspath ):
25- return cls (parent = parent , fspath = fspath )
24+ def from_parent (cls , parent , path ):
25+ return cls (parent = parent , path = path )
2626
2727 def collect (self ):
28- for f in [self .fspath ]:
28+ for f in [self .path ]:
2929 yield NotebookItem .from_parent (self , name = os .path .basename (f ))
3030
3131 def setup (self ):
@@ -44,7 +44,7 @@ def from_parent(cls, parent, name):
4444 return cls (parent = parent , name = name )
4545
4646 def runtest (self ):
47- cur_dir = os .path .dirname (self .fspath )
47+ cur_dir = os .path .dirname (self .path )
4848
4949 # See https://bugs.python.org/issue37373
5050 if (
@@ -56,14 +56,14 @@ def runtest(self):
5656
5757 asyncio .set_event_loop_policy (asyncio .WindowsSelectorEventLoopPolicy ())
5858
59- with self .fspath .open () as f :
59+ with self .path .open () as f :
6060 nb = nbformat .read (f , as_version = 4 )
6161 try :
6262 self .parent .exproc .preprocess (nb , {"metadata" : {"path" : cur_dir }})
6363 except CellExecutionError as e :
6464 raise NotebookException (e )
6565
66- with open (self .fspath , "wt" , encoding = "utf-8" ) as f :
66+ with open (self .path , "wt" , encoding = "utf-8" ) as f :
6767 nbformat .write (nb , f )
6868
6969 def repr_failure (self , excinfo ):
@@ -73,7 +73,7 @@ def repr_failure(self, excinfo):
7373 return super (NotebookItem , self ).repr_failure ((excinfo ))
7474
7575 def reportinfo (self ):
76- return self .fspath , 0 , "TestCase: %s" % self .name
76+ return self .path , 0 , "TestCase: %s" % self .name
7777
7878
7979class NotebookException (Exception ):
0 commit comments