From 99277be25fdcff387098983b7a29b6fb792b8d73 Mon Sep 17 00:00:00 2001 From: Lukasz Balcerzak Date: Thu, 19 Dec 2013 14:29:57 +0100 Subject: [PATCH] Updated error message to be more helpful Also, added misssing test --- _pytest/mark.py | 2 +- testing/test_mark.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/_pytest/mark.py b/_pytest/mark.py index 22eea5ec6..26d1954bb 100644 --- a/_pytest/mark.py +++ b/_pytest/mark.py @@ -169,7 +169,7 @@ class MarkGenerator: def __getattr__(self, name): if name[0] == "_": - raise AttributeError(name) + raise AttributeError("Marker name must NOT start with underscore") if hasattr(self, '_config'): self._check(name) return MarkDecorator(name) diff --git a/testing/test_mark.py b/testing/test_mark.py index d53af59cc..ba4c427fe 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -15,6 +15,10 @@ class TestMark: mark = Mark() pytest.raises((AttributeError, TypeError), mark) + def test_pytest_mark_name_starts_with_underscore(self): + mark = Mark() + pytest.raises(AttributeError, getattr, mark, '_some_name') + def test_pytest_mark_bare(self): mark = Mark() def f():