prepare for Node.fspath deprecation

calculate topdir based on config.rootpath/rootdir

addresses pytest-dev/pytest#8251
This commit is contained in:
Ronny Pfannschmidt
2021-02-07 20:37:40 +01:00
parent ad99d943de
commit aa89c42ad7
2 changed files with 7 additions and 1 deletions

1
changelog/623.bugfix.rst Normal file
View File

@@ -0,0 +1 @@
Gracefully handle the pending deprecation of Node.fspath by using config.rootpath for topdir.

View File

@@ -93,9 +93,14 @@ class WorkerInteractor:
)
def pytest_collection_finish(self, session):
try:
topdir = str(self.config.rootpath)
except AttributeError: # pytest <= 6.1.0
topdir = str(self.config.rootdir)
self.sendevent(
"collectionfinish",
topdir=str(session.fspath),
topdir=topdir,
ids=[item.nodeid for item in session.items],
)