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

Is there a way to provide mark with fixture params #3351

Closed
cauveryguda opened this issue Mar 28, 2018 · 4 comments
Closed

Is there a way to provide mark with fixture params #3351

cauveryguda opened this issue Mar 28, 2018 · 4 comments
Labels
type: question general question, might be closed after 2 weeks of inactivity

Comments

@cauveryguda
Copy link

Currently I don't see and did not find any documentation on a way to provide mark for the params given in fixtures.

For example I have a fixture with 3 params and I would like the test you use only some of the params for test run depending on the -m option given on command. I don't think currently the marks are supported at fixture param level.

FYI I am using mark at the test level parameterize, so looking for something similar at the fixture level param.

Thank you,
Cauvery.

@RonnyPfannschmidt
Copy link
Member

you can use the same mechanism used for parameterize

ideally pytest.param(value, marks=somemark)

@nicoddemus
Copy link
Member

@RonnyPfannschmidt is correct, a quick example:

import pytest

@pytest.fixture(params=[1, pytest.param(2, marks=pytest.mark.slow)])
def fix(request):
    return request.param

def test_f(fix):
    pass
pytest params.py -m "not slow" -q
.
1 passed, 1 deselected in 0.01 seconds

@nicoddemus nicoddemus added the type: question general question, might be closed after 2 weeks of inactivity label Mar 28, 2018
@nicoddemus
Copy link
Member

Noticed there was nothing about that on the docs: #3353

I'm closing this for now @cauveryguda since your question has been answered, but feel free to follow with more.

@cauveryguda
Copy link
Author

Thank you for the answers. Sorry for some reason I have been searching for this and could not find in the documentation. I will give a try for this and keep posted if any issues.

-Cauvery.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question general question, might be closed after 2 weeks of inactivity
Projects
None yet
Development

No branches or pull requests

3 participants