allow test items to not be associated with a test function

this is needed for plugins like `pytest-pep8` or `pytest-flakes`
This commit is contained in:
Andreas Zeidler 2013-10-02 15:55:28 +02:00
parent 05f6422392
commit 42b1033385
1 changed files with 3 additions and 2 deletions

View File

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