Merge pull request #3637 from RonnyPfannschmidt/fix-3631

fix #3631 - don't store legacy markinfo when its impossible
This commit is contained in:
Bruno Oliveira 2018-06-30 17:48:46 -03:00 committed by GitHub
commit 2b75a311a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View File

@ -0,0 +1 @@
No longer raise AttributeError when legacy marks can't be stored.

View File

@ -259,7 +259,7 @@ def store_legacy_markinfo(func, mark):
if holder is None:
holder = MarkInfo.for_mark(mark)
setattr(func, mark.name, holder)
else:
elif isinstance(holder, MarkInfo):
holder.add_mark(mark)

View File

@ -63,6 +63,19 @@ class TestMark(object):
mark.hello(f)
assert f.hello
def test_mark_legacy_ignore_fail(self):
def add_attribute(func):
func.foo = 1
return func
@pytest.mark.foo
@add_attribute
def test_fun():
pass
assert test_fun.foo == 1
assert test_fun.pytestmark
@ignore_markinfo
def test_pytest_mark_keywords(self):
mark = Mark()