From d9bcfa0c2bb0ebf8e0a59c8296625a1eca77da05 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Wed, 6 Oct 2021 22:41:04 +0300 Subject: [PATCH] python: don't redundantly duplicate parent markers to own keywords This does have a slight semantic change: in a node hierarchy parent -> child, if parent has a marker applied, then child is constructed, then `parent.themarker = "overridden"`, previously `child.keywords['themarker']` would return `True`, now it returns `"overridden"`. But that's actually what I would have expected so I see it as more of a bugfix. --- src/_pytest/python.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 71c998c8e..60b2ae20f 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1676,10 +1676,11 @@ class Function(PyobjMixin, nodes.Item): # todo: this is a hell of a hack # https://github.com/pytest-dev/pytest/issues/4569 + # Take own_markers only; NodeKeywords handles parent traversal on its own. self.keywords.update( { mark.name: mark - for mark in self.iter_markers() + for mark in self.own_markers if mark.name not in self.keywords } )