From 853b0a4c299d909b7e543a4307f16e3746d642cd Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sat, 23 Oct 2021 21:33:12 +0300 Subject: [PATCH] nodes: fix bug in Node() fspath compat Since path <-> fspath are converted to each other, we need to check both before looking at the parent, in case fspath is set but path is not. --- src/_pytest/nodes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index 3b70e1117..37b0b3d2b 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -210,9 +210,9 @@ class Node(metaclass=NodeMeta): self.session = parent.session #: Filesystem path where this node was collected from (can be None). - self.path = _imply_path_only( - path or getattr(parent, "path", None), fspath=fspath - ) + if path is None and fspath is None: + path = getattr(parent, "path", None) + self.path = _imply_path_only(path, fspath=fspath) # The explicit annotation is to avoid publicly exposing NodeKeywords. #: Keywords/markers collected from all scopes.