# esss/pytest-regressions architecture

> Architecture diagram of the GitHub repository esss/pytest-regressions, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/esss/pytest-regressions
- Repository: https://github.com/esss/pytest-regressions

## Overview

##### Project type and purpose
- This is an open-source Python plugin for pytest called “pytest-regressions.”
- Purpose: provides fixtures to perform regression tests on various data types (plain files, images, numeric tables, NumPy arrays, etc.) by saving “expected” outputs in a data directory and comparing them on future runs.

##### File structure
- Top-level directories and files:
- src/pytest_regressions/… — core plugin code
- tests/… — test suite with examples of each fixture in action
- doc/… — Sphinx documentation (api, installation, overview)
- .github/workflows/ — CI definitions (build, test, deploy)
- setup.py, tox.ini, mypy.ini, pre-commit config — packaging, linting, typing, local CI
- Within src/pytest_regressions/:
- plugin.py — entry point registering hooks & fixtures
- common.py — shared utilities (I/O, comparison logic)
- data_regression.py, dataframe_regression.py, file_regression.py, image_regression.py, ndarrays_regression.py, num_regression.py — one module per fixture type
- Configuration & metadata:
- setup.py — package metadata & install_requires
- mypy.ini — type-checking rules
- tox.ini — multi-env test orchestration

##### README for additional insights
- Confirms it’s a pytest plugin offering fixtures to simplify regression testing.
- Mentions dependency on pytest-datadir (for managing the expected data directory).
- Encourages contributions, documents testing via tox.
- Generated via cookiecutter-pytest-plugin template.

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Actors
    User["Test Author"]:::actor
    CLI["pytest CLI & Core Engine"]:::external

    %% Plugin Layer
    subgraph "pytest-regressions Plugin" 
        Plugin["Entry Point: plugin.py"]:::plugin
        Common["Common Utilities: common.py"]:::utility
        TestingHelpers["Testing Helpers: testing.py"]:::utility
        subgraph "Fixture Modules"
            DataReg["Fixture: data_regression.py"]:::fixture
            DFReg["Fixture: dataframe_regression.py"]:::fixture
            FileReg["Fixture: file_regression.py"]:::fixture
            ImgReg["Fixture: image_regression.py"]:::fixture
            NDArrayReg["Fixture: ndarrays_regression.py"]:::fixture
            NumReg["Fixture: num_regression.py"]:::fixture
        end
    end

    %% User Test Suite & Data
    subgraph "User Test Suite"
        Tests["tests/ (user tests)"]:::tests
    end
    subgraph "Regression Data Directory"
        DR["tests/test_data_regression/"]:::data
        DFR["tests/test_dataframe_regression/"]:::data
        FRF["tests/test_file_regression/"]:::data
        IR["tests/test_image_regression/"]:::data
        NR["tests/test_ndarrays_regression/"]:::data
        NMR["tests/test_num_regression/"]:::data
    end

    %% External Libraries
    subgraph "External Dependencies"
        PytestDatadir["pytest-datadir"]:::external
        Numpy["NumPy"]:::external
        Pandas["Pandas"]:::external
        PIL["Pillow/imageio"]:::external
    end

    %% Configuration & Packaging
    subgraph "Configuration & Packaging"
        Setup["setup.py"]:::config
        Mypy["mypy.ini / py.typed"]:::config
        Tox["tox.ini"]:::config
        Precommit[".pre-commit-config.yaml"]:::config
    end

    %% CI/CD & Documentation
    subgraph "CI/CD & Documentation"
        GHTest[".github/workflows/test.yml"]:::ci
        GHDeploy[".github/workflows/deploy.yml"]:::ci
        DocsSource["doc/"]:::docs
        RTD[".readthedocs.yaml"]:::docs
    end

    %% Connections
    User -->|"runs pytest"| CLI
    CLI -->|"loads plugin via entry point"| Plugin
    Plugin -->|registers fixtures| DataReg
    Plugin -->|registers fixtures| DFReg
    Plugin -->|registers fixtures| FileReg
    Plugin -->|registers fixtures| ImgReg
    Plugin -->|registers fixtures| NDArrayReg
    Plugin -->|registers fixtures| NumReg
    DataReg -->|uses| Common
    DFReg -->|uses| Common
    FileReg -->|uses| Common
    ImgReg -->|uses| Common
    NDArrayReg -->|uses| Common
    NumReg -->|uses| Common
    Common -->|reads/writes| DR
    Common -->|reads/writes| DFR
    Common -->|reads/writes| FRF
    Common -->|reads/writes| IR
    Common -->|reads/writes| NR
    Common -->|reads/writes| NMR
    Tests -->|invoke fixtures| DataReg
    Tests -->|invoke fixtures| DFReg
    Tests -->|invoke fixtures| FileReg
    Tests -->|invoke fixtures| ImgReg
    Tests -->|invoke fixtures| NDArrayReg
    Tests -->|invoke fixtures| NumReg
    DataReg -->|may call| PytestDatadir
    DFReg -->|depends on| Pandas
    DFReg -->|depends on| Numpy
    NDArrayReg -->|depends on| Numpy
    ImgReg -->|depends on| PIL
    CLI -->|via tox| Tox
    Tox -->|runs| CLI
    GHTest -->|triggers| Tox
    GHDeploy -->|on release| Setup
    Setup -->|publishes to| RTD
    DocsSource -->|built by| GHTest
    DocsSource -->|deployed to| RTD

    %% Click Events
    click Plugin "https://github.com/esss/pytest-regressions/blob/master/src/pytest_regressions/plugin.py"
    click Common "https://github.com/esss/pytest-regressions/blob/master/src/pytest_regressions/common.py"
    click DataReg "https://github.com/esss/pytest-regressions/blob/master/src/pytest_regressions/data_regression.py"
    click DFReg "https://github.com/esss/pytest-regressions/blob/master/src/pytest_regressions/dataframe_regression.py"
    click FileReg "https://github.com/esss/pytest-regressions/blob/master/src/pytest_regressions/file_regression.py"
    click ImgReg "https://github.com/esss/pytest-regressions/blob/master/src/pytest_regressions/image_regression.py"
    click NDArrayReg "https://github.com/esss/pytest-regressions/blob/master/src/pytest_regressions/ndarrays_regression.py"
    click NumReg "https://github.com/esss/pytest-regressions/blob/master/src/pytest_regressions/num_regression.py"
    click TestingHelpers "https://github.com/esss/pytest-regressions/blob/master/src/pytest_regressions/testing.py"
    click Tests "https://github.com/esss/pytest-regressions/tree/master/tests/"
    click DR "https://github.com/esss/pytest-regressions/tree/master/tests/test_data_regression/"
    click DFR "https://github.com/esss/pytest-regressions/tree/master/tests/test_dataframe_regression/"
    click FRF "https://github.com/esss/pytest-regressions/tree/master/tests/test_file_regression/"
    click IR "https://github.com/esss/pytest-regressions/tree/master/tests/test_image_regression/"
    click NR "https://github.com/esss/pytest-regressions/tree/master/tests/test_ndarrays_regression/"
    click NMR "https://github.com/esss/pytest-regressions/tree/master/tests/test_num_regression/"
    click Setup "https://github.com/esss/pytest-regressions/blob/master/setup.py"
    click Mypy "https://github.com/esss/pytest-regressions/blob/master/mypy.ini"
    click Tox "https://github.com/esss/pytest-regressions/blob/master/tox.ini"
    click Precommit "https://github.com/esss/pytest-regressions/blob/master/.pre-commit-config.yaml"
    click GHTest "https://github.com/esss/pytest-regressions/blob/master/.github/workflows/test.yml"
    click GHDeploy "https://github.com/esss/pytest-regressions/blob/master/.github/workflows/deploy.yml"
    click DocsSource "https://github.com/esss/pytest-regressions/tree/master/doc/"
    click RTD "https://github.com/esss/pytest-regressions/blob/master/.readthedocs.yaml"

    %% Styles
    classDef plugin fill:#ffd700,stroke:#333,stroke-width:1px
    classDef utility fill:#ffdead,stroke:#333,stroke-width:1px
    classDef fixture fill:#add8e6,stroke:#333,stroke-width:1px
    classDef tests fill:#90ee90,stroke:#333,stroke-width:1px
    classDef data fill:#ffe4e1,stroke:#333,stroke-width:1px
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef actor fill:#ffb6c1,stroke:#333,stroke-width:1px
    classDef config fill:#e6e6fa,stroke:#333,stroke-width:1px
    classDef ci fill:#fafad2,stroke:#333,stroke-width:1px
    classDef docs fill:#e0ffff,stroke:#333,stroke-width:1px
```
