我正在尝试与传统的单元测试分开运行夹具测试。
为此,我用@pytest.mark.fixtures
装饰器标记了所有灯具,例如:
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
,然后运行两个pytest命令(在tox内):
pytest -v -m fixtures --junitxml={toxinidir}/tests/output/pytest-fixtures.xml
pytest -v -m "not fixtures" --junitxml={toxinidir}/tests/output/pytest.xml
问题是第二次pytest运行仍会创建会话固定装置,尽管我不会使用它,因为我跳过了上面带有fixtures
标记的测试。
如何在第二次“非固定装置”运行中禁用固定装置(或跳过会话范围的固定装置)?