diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index c3235f8b8..4a249c8fd 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -571,6 +571,15 @@ def visit( yield from visit(entry.path, recurse) +def absolutepath(path: Union[Path, str]) -> Path: + """Convert a path to an absolute path using os.path.abspath. + + Prefer this over Path.resolve() (see #6523). + Prefer this over Path.absolute() (not public, doesn't normalize). + """ + return Path(os.path.abspath(str(path))) + + def commonpath(path1: Path, path2: Path) -> Optional[Path]: """Return the common part shared with the other path, or None if there is no common part."""