Skip to content

fix #3631 - don't store legacy markinfo when its impossible #3637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/3631.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No longer raise AttributeError when legacy marks can't be stored.
2 changes: 1 addition & 1 deletion src/_pytest/mark/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
13 changes: 13 additions & 0 deletions testing/test_mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ def f():
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()
Expand Down