index.rst

Overview

The `index.rst` file serves as the central documentation index for the "How-to guides" section of the pytest documentation. It organizes and presents a structured table of contents (ToC) that links to various detailed guides covering pytest's core functionality, test output handling, plugin development, integration with other test systems, and development environment setup.

Its primary purpose is to facilitate easy navigation through pytest's extensive documentation by grouping related topics under clear headings and providing quick access to individual how-to documents. This file is written in reStructuredText (reST) format and uses Sphinx directives to create automatic ToCs.

Key functionalities include:

Detailed Explanation

This file does not contain classes, functions, or methods but employs reST markup and Sphinx directives. Below is an explanation of its components and usage.

Document Structure and Sphinx Directives

Sections and Linked Documents

Each ToC groups related topics:

  1. Core pytest functionality
    Includes guides on:

    • usage

    • assert

    • fixtures

    • mark

    • parametrize

    • tmp_path

    • monkeypatch

    • doctest

    • cache

  2. Test output and outcomes
    Topics on:

    • failures

    • output

    • logging

    • capture-stdout-stderr

    • capture-warnings

    • skipping

  3. Plugins
    Guides for:

    • plugins

    • writing_plugins

    • writing_hook_functions

  4. pytest and other test systems
    Guides on integrating pytest with:

    • existingtestsuite

    • unittest

    • xunit_setup

  5. pytest development environment
    Setup guide for:

    • bash-completion

Usage Example

This file is referenced as part of the pytest documentation build process. When Sphinx builds the docs, it reads `index.rst` to generate the "How-to guides" landing page, displaying the organized links.

A user or contributor wanting to find pytest usage examples or plugin development instructions would start here to navigate.

# In the documentation, this will render as:

How-to guides
=============

Core pytest functionality
-------------------------
- usage
- assert
- fixtures
...

Test output and outcomes
-----------------------
- failures
- output
...

Plugins
-------
- plugins
- writing_plugins
...

pytest and other test systems
-----------------------------
- existingtestsuite
- unittest
...

pytest development environment
------------------------------
- bash-completion

Implementation Details

Interaction with Other Parts of the System

Visual Diagram

The following Mermaid class diagram illustrates the conceptual structure of this documentation index file, showing its main sections and their linked documents as "methods" to represent available topics.

classDiagram
    class index_rst {
        <<Document>>
        +Core_pytest_functionality()
        +Test_output_and_outcomes()
        +Plugins()
        +pytest_and_other_test_systems()
        +pytest_development_environment()
    }

    class Core_pytest_functionality {
        +usage
        +assert
        +fixtures
        +mark
        +parametrize
        +tmp_path
        +monkeypatch
        +doctest
        +cache
    }

    class Test_output_and_outcomes {
        +failures
        +output
        +logging
        +capture_stdout_stderr
        +capture_warnings
        +skipping
    }

    class Plugins {
        +plugins
        +writing_plugins
        +writing_hook_functions
    }

    class pytest_and_other_test_systems {
        +existingtestsuite
        +unittest
        +xunit_setup
    }

    class pytest_development_environment {
        +bash_completion
    }

    index_rst --> Core_pytest_functionality
    index_rst --> Test_output_and_outcomes
    index_rst --> Plugins
    index_rst --> pytest_and_other_test_systems
    index_rst --> pytest_development_environment

Summary

This file is essential for structuring the pytest documentation and improving user experience by categorizing and centralizing access to core how-to content.