use getfixturemarker

This commit is contained in:
Thomas Grainger 2022-10-09 20:23:53 +01:00
parent aa9cc7e8b4
commit a1b10b552a
No known key found for this signature in database
GPG Key ID: DDA48B5C47FBC8C8
1 changed files with 6 additions and 3 deletions

View File

@ -387,11 +387,14 @@ def store_mark(obj, mark: Mark) -> None:
This is used to implement the Mark declarations/decorators correctly.
"""
assert isinstance(mark, Mark), mark
# Always reassign name to avoid updating pytestmark in a reference that
# was only borrowed.
if hasattr(obj, "_pytestfixturefunction"):
from ..fixtures import getfixturemarker
if getfixturemarker(obj) is not None:
warnings.warn(MARKED_FIXTURE, stacklevel=2)
# Always reassign name to avoid updating pytestmark in a reference that
# was only borrowed.
obj.pytestmark = [*get_unpacked_marks(obj), mark]