player nicer for missing parent Module objects for a collected function (bug triggered by oejskit)

--HG--
branch : trunk
This commit is contained in:
holger krekel 2009-10-20 16:38:12 +02:00
parent fabd967595
commit 9910db2ca6
2 changed files with 5 additions and 1 deletions

View File

@ -175,6 +175,7 @@ def getexpression(item, keyword):
if cls and hasattr(cls.obj, keyword):
return getattr(cls.obj, keyword)
mod = item.getparent(py.test.collect.Module)
if mod:
return getattr(mod.obj, keyword, None)
def evalexpression(item, keyword):

View File

@ -110,6 +110,9 @@ def test_getexpression(testdir):
assert getexpression(item2, 'just')
item2.parent = None
assert not getexpression(item2, 'nada')
def test_evalexpression_cls_config_example(testdir):
from _py.test.plugin.pytest_skipping import evalexpression
item, = testdir.getitems("""