Configuring Pytest to Run Doctest | by Marcin Kozak | Apr, 2024

Editor
1 Min Read


PYTHON PROGRAMMING

Learn how to configure pytest in pyproject.toml to run doctests

Photo by Paul Hanaoka on Unsplash

Modern Python projects are managed by pyproject.toml files. You can use it to manage both regular projects and Python packages, which makes this file a general tool to set up Python projects of various types.

The pyproject.toml file can contain everything your project needs, like:

  • Metadata, such as the name of the project, version, authors, license, classifiers, URL, and description (both short and long).
  • The configuration of the development and production environment, meaning dependencies and optional dependencies.
  • Configuration of development tools, such as black, ruff, pylint, pytest, and many others.

When the project gets big, you can move much of this information to other configuration files, like pytest.ini, requirements.txt, requirements_dev.txt, and so on. But when a pyproject.toml doesn’t get overly long, I keep all the information inside it — this makes the project’s root directory small.

This is just basic information about pyproject.toml files. If you want to learn more about using it, you can do so from here:

Share this Article
Please enter CoinGecko Free Api Key to get this plugin works.