From 42b10333854ef63bb49baba3eff71e4e58aaeeab Mon Sep 17 00:00:00 2001 From: Andreas Zeidler Date: Wed, 2 Oct 2013 15:55:28 +0200 Subject: [PATCH] allow test items to not be associated with a test function this is needed for plugins like `pytest-pep8` or `pytest-flakes` --- _pytest/mark.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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))