Pytest ArrayDiff

0.6.1 · active · verified Wed Apr 15

pytest-arraydiff is a pytest plugin designed to facilitate the generation and comparison of large data arrays produced during tests, avoiding the need to hard-code them. It allows tests to generate reference files or compare results against existing references within specified tolerances. The current version is 0.6.1, with releases occurring on an irregular but active cadence, typically every few months.

Warnings

Install

Imports

Quickstart

Mark a test function with `@pytest.mark.array_compare` and have it return the array to be compared. Run pytest with `--arraydiff-generate-path` to create reference files or without it to perform comparisons against existing reference data.

import pytest
import numpy as np

@pytest.mark.array_compare
def test_succeeds():
    # This test will generate or compare an array
    # run with `pytest --arraydiff-generate-path=reference_data`
    # or `pytest --arraydiff-default-format=text`
    return np.arange(3 * 5 * 4).reshape((3, 5, 4))

view raw JSON →