Skip to content
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

request.node.get_marker('name') returns None for markers applied in classes #902

Closed
norbertpy opened this issue Jul 29, 2015 · 7 comments
Closed
Labels
topic: marks related to marks, either the general marks or builtin type: bug problem that needs to be addressed

Comments

@norbertpy
Copy link

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)
@nicoddemus
Copy link
Member

I could reproduce the problem in master, thanks for reporting it.

It seems related to markers applied to classes (I updated the title to match this).

@nicoddemus nicoddemus changed the title request.node.get_marker('name') returns None regardless of applied marker request.node.get_marker('name') returns None for markers applied in classes Jul 29, 2015
@nicoddemus nicoddemus added the type: bug problem that needs to be addressed label Jul 29, 2015
@norbertpy
Copy link
Author

@nicoddemus , thank you. Do I get notified if it's fixed?

@nicoddemus
Copy link
Member

Yes, you're watching this thread because you submitted this issue. 😄

Thanks again.

@RonnyPfannschmidt
Copy link
Member

this issue is related to marker transfers

i believe the most correct fix would be implementing #891 however it comes with compatibility issues

@The-Compiler
Copy link
Member

Removing the milestone here, as this shouldn't block 3.0 and we have #1670 (where I set the milestone to 4.0 for now) to track all marker staining related issues.

@The-Compiler The-Compiler removed this from the 3.0 milestone Aug 5, 2016
@RonnyPfannschmidt RonnyPfannschmidt added the topic: marks related to marks, either the general marks or builtin label May 14, 2017
@RonnyPfannschmidt
Copy link
Member

this one can be solved after #2522

@RonnyPfannschmidt
Copy link
Member

fixed in #3317

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: marks related to marks, either the general marks or builtin type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

4 participants