Fix rsyncdirs usage with pytest 6.0

Fix pytest-dev/pytest#7487
This commit is contained in:
Bruno Oliveira
2020-07-13 12:01:16 -03:00
parent 727c41e957
commit 443dc21061
3 changed files with 11 additions and 3 deletions

View File

@@ -90,8 +90,16 @@ class NodeManager(object):
import pytest
import _pytest
pytestpath = pytest.__file__.rstrip("co")
pytestdir = py.path.local(_pytest.__file__).dirpath()
def get_dir(p):
"""Return the directory path if p is a package or the path to the .py file otherwise."""
stripped = p.rstrip("co")
if os.path.basename(stripped) == "__init__.py":
return os.path.dirname(p)
else:
return stripped
pytestpath = get_dir(pytest.__file__)
pytestdir = get_dir(_pytest.__file__)
config = self.config
candidates = [py._pydir, pytestpath, pytestdir]
candidates += config.option.rsyncdir