diff --git a/py/test/outcome.py b/py/test/outcome.py index 6994c243e..66a6c2c95 100644 --- a/py/test/outcome.py +++ b/py/test/outcome.py @@ -161,6 +161,8 @@ class KeywordDecorator: return func def __getattr__(self, name): + if name[0] == "_": + raise AttributeError(name) kw = self._keywords.copy() kw[name] = True return self.__class__(kw, lastname=name) diff --git a/py/test/testing/test_outcome.py b/py/test/testing/test_outcome.py index 9c1d5115f..a11691cc4 100644 --- a/py/test/testing/test_outcome.py +++ b/py/test/testing/test_outcome.py @@ -76,8 +76,20 @@ def test_importorskip(): print py.code.ExceptionInfo() py.test.fail("spurious skip") +def test_pytest_mark_getattr(): + from py.__.test.outcome import mark + def f(): pass -def test_pytest_mark(): + mark.hello(f) + assert f.hello == True + + mark.hello("test")(f) + assert f.hello == "test" + + py.test.raises(AttributeError, "mark._hello") + py.test.raises(AttributeError, "mark.__str__") + +def test_pytest_mark_call(): from py.__.test.outcome import mark def f(): pass mark(x=3)(f)