Merge pull request #9 from lukaszb/mark-error-message

Updated error message to be more helpful.
This commit is contained in:
holger krekel 2013-12-19 07:13:13 -08:00
commit 49b9f9091a
2 changed files with 5 additions and 1 deletions

View File

@ -169,7 +169,7 @@ class MarkGenerator:
def __getattr__(self, name): def __getattr__(self, name):
if name[0] == "_": if name[0] == "_":
raise AttributeError(name) raise AttributeError("Marker name must NOT start with underscore")
if hasattr(self, '_config'): if hasattr(self, '_config'):
self._check(name) self._check(name)
return MarkDecorator(name) return MarkDecorator(name)

View File

@ -15,6 +15,10 @@ class TestMark:
mark = Mark() mark = Mark()
pytest.raises((AttributeError, TypeError), 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): def test_pytest_mark_bare(self):
mark = Mark() mark = Mark()
def f(): def f():