diff --git a/conftest.py b/conftest.py
index ceee053709d1c5699b50d98ee08b1225466ede65..ebd72bdc77cc352960a98b4a763feb18ce76628a 100644
--- a/conftest.py
+++ b/conftest.py
@@ -126,7 +126,7 @@ class IPyNbFile(pytest.File):
         exporter.exclude_markdown = True
         exporter.exclude_input_prompt = True
 
-        notebook_contents = self.path.open(encoding='utf-8')
+        notebook_contents = self.fspath.open(encoding='utf-8')
 
         with warnings.catch_warnings():
             warnings.filterwarnings("ignore", "IPython.core.inputsplitter is deprecated")
@@ -145,6 +145,6 @@ def pytest_collect_file(path, parent):
     glob_exprs = ["*demo*.ipynb", "*tutorial*.ipynb", "test_*.ipynb"]
     if any(path.fnmatch(g) for g in glob_exprs):
         if pytest_version >= 50403:
-            return IPyNbFile.from_parent(path=path, parent=parent)
+            return IPyNbFile.from_parent(fspath=path, parent=parent)
         else:
             return IPyNbFile(path, parent)