How to disable pytest fixtures?

Viewed 354

I'm trying to run fixture tests separately from the classic unit tests.

For that end, I've marked all the fixtures with @pytest.mark.fixtures decorator, for example:

conftest.py

@pytest.fixture(scope="session")
def fs():
    pass

test_something.py

@pytest.mark.fixtures
def test_xxx(fs):
    pass

@pytest.mark.fixtures
def test_yyy():
    pass

and then ran two pytest commands (within tox):

pytest -v -m fixtures --junitxml={toxinidir}/tests/output/pytest-fixtures.xml
pytest -v -m "not fixtures" --junitxml={toxinidir}/tests/output/pytest.xml

The problem is that the second pytest run still creates my session fixture, although I will not use it because I'm skipping the tests marked with the above fixtures mark.


How can I disable the fixture on the second "not fixtures" run (or skip the session-scoped fixture)?

0 Answers
Related