Configuration TOML native

pytest 9.0 supporte nativement la configuration dans pyproject.toml via la section [tool.pytest.ini_options]. Cette approche remplace avantageusement les fichiers pytest.ini et setup.cfg en centralisant la configuration du projet.

Exemple de configuration

toml
# pyproject.toml
[tool.pytest.ini_options]
minversion = "9.0"
addopts = "-ra -q --strict-markers"
testpaths = ["tests"]
markers = [
    "slow: tests lents (désactivés par défaut)",
    "integration: tests d'intégration",
]
filterwarnings = [
    "error",
    "ignore::DeprecationWarning",
]

Comparé à pytest.ini, le format TOML offre un typage natif (listes, booléens) et permet de regrouper toute la configuration du projet dans un seul fichier.

Sources