diff --git a/_pytest/mark.py b/_pytest/mark.py index 59c72607e..22a6729e6 100644 --- a/_pytest/mark.py +++ b/_pytest/mark.py @@ -139,8 +139,9 @@ def matchkeyword(colitem, keywordexpr): mapped_names.add(name) # Add the names attached to the current function through direct assignment - for name in colitem.function.__dict__: - mapped_names.add(name) + if hasattr(colitem, 'function'): + for name in colitem.function.__dict__: + mapped_names.add(name) return eval(keywordexpr, {}, KeywordMapping(mapped_names))