Closed
Description
I don't know why, but I can't get the marker from my fixture. The request.node.get_marker()
seems to return None
regardless of the marker applied to class:
@pytest.fixture(scope='class')
def my_fixture(request):
marker = request.node.get_marker('joe') # Is always None
@pytest.mark.joe
class TestMarker(object):
def test_marker(self, my_fixture):
assert True
I even registered the marker in my pytest.ini
file:
# content of pytest.ini
[pytest]
markers =
joe: mark a test as joejoejoe
Is this a bug or I'm missing something? Not to mention, I'm using 2.7.2
version.
Update 1:
If I get rid of the class and apply the marker to a function, it'll work:
@pytest.mark.joe
def test_marker(my_fixture):
assert True
Update 2:
This actually works:
@pytest.fixture(scope='class')
def my_fixture(request):
marker = next((m for m in request.cls.pytestmark if m.name == 'joe'), None)