Skip to content

Commit

Permalink
store pristine marks on function.pytestmark
Browse files Browse the repository at this point in the history
  • Loading branch information
RonnyPfannschmidt committed Jun 22, 2017
1 parent 64ae6ae commit 19b12b2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions _pytest/mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ def __call__(self, *args, **kwargs):
apply_mark(func, self.mark)
else:
apply_legacy_mark(func, self.mark)
apply_mark(func, self.mark)
return func

mark = Mark(self.name, args, kwargs)
Expand Down
24 changes: 23 additions & 1 deletion testing/test_mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

import pytest
from _pytest.mark import MarkGenerator as Mark, ParameterSet
from _pytest.mark import MarkGenerator as Mark, ParameterSet, transfer_markers

class TestMark(object):
def test_markinfo_repr(self):
Expand Down Expand Up @@ -772,3 +772,25 @@ def assert_test_is_not_selected(keyword):
def test_parameterset_extractfrom(argval, expected):
extracted = ParameterSet.extract_from(argval)
assert extracted == expected


def test_legacy_transfer():

class FakeModule(object):
pytestmark = []

class FakeClass(object):
pytestmark = pytest.mark.nofun

@pytest.mark.fun
def fake_method(self):
pass


transfer_markers(fake_method, FakeClass, FakeModule)

# legacy marks transfer smeared
assert fake_method.nofun
assert fake_method.fun
# pristine marks dont transfer
assert fake_method.pytestmark == [pytest.mark.fun.mark]

0 comments on commit 19b12b2

Please sign in to comment.