From e2bbee8bbd552cdb14c407589dc34ff7e0903011 Mon Sep 17 00:00:00 2001 From: hpk Date: Mon, 16 Mar 2009 17:04:18 +0100 Subject: [PATCH] [svn r62974] don't allow "_" in py.test.mark attributes --HG-- branch : trunk --- py/test/outcome.py | 2 ++ py/test/testing/test_outcome.py | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) 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)