From 6393893aa848cb1c4c8d57cbef827cf6e3de519d Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Sun, 7 Feb 2021 17:56:23 +0100 Subject: [PATCH] WIP: fix relative path finding when parent.path == self.path --- src/_pytest/nodes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index a8cac4b52d0..378b6ede3f5 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -536,9 +536,9 @@ def __init__( ) -> None: path, fspath = _imply_path(path, fspath=fspath) name = fspath.basename - if parent is not None: + if parent is not None and parent.path != path: try: - rel = Path(fspath).relative_to(parent.path) + rel = path.relative_to(parent.path) except ValueError: pass else: