neuroinformatics-unit / python-cookiecutter

Utility to create a basic Python project structure with tests, CI etc.
BSD 3-Clause "New" or "Revised" License
20 stars 3 forks source link

Add config to error when warnings raised during tests #46

Closed dstansby closed 6 months ago

dstansby commented 1 year ago

In general it's good practice to raise an error in tests when a warning is emitted by code. This can be done by adding the following to pyproject.toml:

[tool.pytest.ini_options]
filterwarnings = [
    "error",
]

This serves several purposes:

pytest has tools to catch or filter warnings where they are intended: https://docs.pytest.org/en/stable/how-to/capture-warnings.html