[py-svn] py-trunk commit d9645744d8a5: player nicer for missing parent Module objects for a collected function (bug triggered by oejskit)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Oct 20 16:42:42 CEST 2009


# HG changeset patch -- Bitbucket.org
# Project py-trunk
# URL http://bitbucket.org/hpk42/py-trunk/overview/
# User holger krekel <holger at merlinux.eu>
# Date 1256049492 -7200
# Node ID d9645744d8a5a9f9fefe55698d2513ab966461e3
# Parent 0d98a3be27c4c3234a3771a5b23c3c58a39e3003
player nicer for missing parent Module objects for a collected function (bug triggered by oejskit)

--- a/_py/test/plugin/pytest_skipping.py
+++ b/_py/test/plugin/pytest_skipping.py
@@ -175,7 +175,8 @@ def getexpression(item, keyword):
         if cls and hasattr(cls.obj, keyword):
             return getattr(cls.obj, keyword)
         mod = item.getparent(py.test.collect.Module)
-        return getattr(mod.obj, keyword, None)
+        if mod:
+            return getattr(mod.obj, keyword, None)
 
 def evalexpression(item, keyword):
     expr = getexpression(item, keyword)

--- a/testing/pytest/plugin/test_pytest_skipping.py
+++ b/testing/pytest/plugin/test_pytest_skipping.py
@@ -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("""



More information about the pytest-commit mailing list