Testing#
It is very important to have tests for verification of your code. There are several types of tests, see for instance Atlassian for a summary.
The most important types of tests are the unit tests, which tests the core functionality of your code.
The most common testing suite for Python in pytest, which can be installed from the Python Package Index (PYPI) using
python -m pip install pytest
You can run pytest
as
python -m pytest
Pytest will then find all files with names like test_*.py
and *_test.py
, see: Conventions for test discovery for more information.
We add the following information to pyproject.toml under table header: [project.optional-dependencies]
[project.optional-dependencies]
# Other entries
# ....
test = [
"pytest",
]
[tool.pytest.ini_options]
addopts = [
"--import-mode=importlib",
# Other entries ....
]
The last option is due to pytest’s recommendation for new projects, see Choosing an import mode for more information.
For other inputs to [tool.pytest.ini_options]
see: https://docs.pytest.org/en/latest/reference/customize.html#pyproject-toml