Átomo
88Mr
pytest · Python

markers e opções

Abrir na tabela

Definição

Marcam testes (lentos, integração) e controlam a execução pela linha de comando.

Exemplos

1. Marcar e selecionar
@pytest.mark.slow
def test_full_load():
    ...

# pytest -m "not slow"
2. Saltar condicionalmente
@pytest.mark.skipif(os.getenv("ENV") != "ci", reason="needs CI database")
def test_integration():
    ...
3. Opções úteis
pytest -x            # stop at first failure
pytest -k "dedup"    # tests whose name contains dedup
pytest --cov=etl     # coverage (pytest-cov)

No mesmo grupo