-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
topic: marksrelated to marks, either the general marks or builtinrelated to marks, either the general marks or builtin
Description
If I add the same marker at different code levels (module, class, function) the args of the combined marker will be taken from the "closest" marker and the kwargs from the "farthest" marker.
Example Test
from pytest import mark
pytestmark = mark.test("argument0", Key0="Value0")
@mark.test("argument1", Key0="Value1")
class TestWithClassMarker(object):
@mark.test("argument2", Key0="Value2")
def test_marker(self, request):
test_marker = request.node.get_marker('test')
test_kwargs = test_marker.kwargs
test_args = test_marker.args
assert test_args[0] == "argument2"
assert test_kwargs['Key0'] == "Value2"
Result
@mark.test("argument2", Key0="Value2")
def test_marker(self, request):
test_marker = request.node.get_marker('test')
test_kwargs = test_marker.kwargs
test_args = test_marker.args
assert test_args[0] == "argument2"
> assert test_kwargs['Key0'] == "Value2"
E AssertionError: assert 'Value0' == 'Value2'
E - Value0
E ? ^
E + Value2
E ? ^
Metadata
Metadata
Assignees
Labels
topic: marksrelated to marks, either the general marks or builtinrelated to marks, either the general marks or builtin