PYTHON PROGRAMMING
Modern Python projects are managed by pyproject.toml
files. You should utilize it to administer each regular projects and Python packages, which makes this file a general tool to establish Python projects of varied types.
The pyproject.toml
file can contain the whole lot your project needs, like:
- Metadata, corresponding to the name of the project, version, authors, license, classifiers, URL, and outline (each short and long).
- The configuration of the event and production environment, meaning dependencies and optional dependencies.
- Configuration of development tools, corresponding to
black
,ruff
,pylint
,pytest
, and lots of others.
When the project gets big, you may move much of this information to other configuration files, like pytest.ini
, requirements.txt
, requirements_dev.txt
, and so forth. But when a pyproject.toml
doesn’t get overly long, I keep all the data inside it — this makes the project’s root directory small.
That is just basic details about pyproject.toml
files. If you desire to learn more about using it, you may accomplish that from here:
In this text, I need to debate a selected scenario during which we are able to use a pyproject.toml
file with a view to configure pytest
to run doctest
tests. As you will note, it’s quite simple to attain. With this simplicity, you’ll receive a really powerful tool: a test runner for each pytest
and doctest
tests. I may even show you learn how to configure doctest
s, including typical doctest
flags and running doctest
tests implemented in each documentation files and Python scripts.
As a way to show learn how to do that, we’ll work with a brand recent Python package. I’ll create its structure using the makepackage
package: