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.
This commit is contained in:
Ran Benita 2021-10-06 22:41:04 +03:00
parent 8713c32462
commit d9bcfa0c2b
1 changed files with 2 additions and 1 deletions

View File

@ -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
}
)