-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
topic: marksrelated to marks, either the general marks or builtinrelated to marks, either the general marks or builtintype: bugproblem that needs to be addressedproblem that needs to be addressedtype: regressionindicates a problem that was introduced in a release which was working previouslyindicates a problem that was introduced in a release which was working previously
Description
When we are using parametrize regarding to doc and in pytest hook pytest_collection_modifyitems we would like to get marker and it's value we are failing with error:
ValueError: MarkInfo expects Mark instances, got MarkDecorator(mark=Mark(name='custom_mark', args=('custom mark1',), kwargs={})) (<class '_pytest.mark.structures.MarkDecorator'>)
How to reproduce:
I attached full example,, you just need to run_test.sh script.
- requirement file is part of attached examle, contains just latest pytest@features branch
- latest - features branch
- Minimal example if possible, attached pytest_marker_issue.tar.gz
test_file.py:
import pytest
first_custom_mark = pytest.mark.custom_marker
custom_mark = pytest.mark.custom_mark
@custom_mark("custom mark non parametrized")
def test_custom_mark_non_parametrized():
print "Hey from test"
@pytest.mark.parametrize(
"obj_type",
[
first_custom_mark("first custom mark")("template"),
pytest.param( # Think this should be recommended way?
"disk",
marks=custom_mark('custom mark1')
),
custom_mark("custom mark2")("vm"), # Tried also this
]
)
def test_custom_mark_parametrized(obj_type):
print "obj_type is: %s" % obj_type
conftest.py
def pytest_collection_modifyitems(session, config, items):
for item in items:
# here we are failing with:
# INTERNALERROR> ValueError: MarkInfo expects Mark instances, got
# MarkDecorator(mark=Mark(name='custom_mark', args=('custom mark1',), kwargs={})) (<class '_pytest.mark.structures.MarkDecorator'>)
custom_mark = item.get_marker('custom_mark')
print("Custom mark %s" % custom_mark)
Metadata
Metadata
Assignees
Labels
topic: marksrelated to marks, either the general marks or builtinrelated to marks, either the general marks or builtintype: bugproblem that needs to be addressedproblem that needs to be addressedtype: regressionindicates a problem that was introduced in a release which was working previouslyindicates a problem that was introduced in a release which was working previously