What Is A Pytest Config File?
In Python, there are many types of config files, notably pyproject.toml
, setup.cfg
and so on.
Now Pytest has it’s own default config file called pytest.ini
, which takes precedence over other config files.
pytest.ini
pytest.ini
is the default Pytest config file that can be used to specify just about any Pytest setting.
It takes precedence over other config files, even when empty.
pyproject.toml
pyproject.toml
is the new defacto Python config file for dependency management and packaging. You can declare project metadata, dependencies, and development dependencies.
It allows you to specify Python version compatibility. Below is a simple pyproject.toml
file,
You can use tooling like Poetry or Flit to build and package your project using pyproject.toml
.
setup.cfg
setup.cfg
is the legacy configuration file for Python packaging.
You can easily define package metadata like name, version, description, and author. It also supports specifying package classifiers and keywords. Following is a simple setup.cfg
file:
tox.ini
Tox is a useful tool to automate and standardize testing in different environments. It enables you to test environments and dependencies for testing across different Python versions.
Conveniently, you can also define Pytest configurations in tox.ini
.