Используйте and
/ or
для объединения нескольких маркеров, так же как для селектора -k
. Пример набора тестов:
import pytest
@pytest.mark.foo
def test_spam():
assert True
@pytest.mark.foo
def test_spam2():
assert True
@pytest.mark.bar
def test_eggs():
assert True
@pytest.mark.foo
@pytest.mark.bar
def test_eggs2():
assert True
def test_bacon():
assert True
Выбор всех тестов, отмеченных foo
и не отмеченных bar
$ pytest -q --collect-only -m "foo and not bar"
test_mod.py::test_spam
test_mod.py::test_spam2
Выбор всех тестов, отмеченных ни foo
, ни bar
$ pytest -q --collect-only -m "not foo and not bar"
test_mod.py::test_bacon
Выбор тестов, помеченных любым из foo
, bar
$ pytest -q --collect-only -m "foo or bar"
test_mod.py::test_spam
test_mod.py::test_spam2
test_mod.py::test_eggs
test_mod.py::test_eggs2