Skip to main content

pytest plugin for snapshot regression testing

Project description

The full documentation for this package are available at https://pytest-regtest.readthedocs.org

About

Introduction

pytest-regtest is a plugin for pytest to implement regression testing.

Unlike functional testing, regression testing does not test whether the software produces the correct results, but whether it behaves as it did before changes were introduced.

More specifically, pytest-regtest provides snapshot testing, which implements regression testing by recording data within a test function and comparing this recorded output to a previously recorded reference output.

Installation

To install and activate this plugin execute:

$ pip install pytest-regtest

!!! note

 `pytest-regtest` provides some functionality specific to `NumPy`,
 `pandas`, and `polars`. These dependencies are not installed when
 you install `pytest-regtest`. For example, if you are using NumPy
 snapshots, we assume that your production code (the code under
 test) uses NumPy and therefore should be part of your project's
 setup.

Use case 1: Changing code with no or little testing setup yet

If you're working with code that has little or no unit testing, you can use regression testing to ensure that your changes don't break or alter previous results.

Example: This can be useful when working with data analysis scripts, which often start as one long script and then are restructured into different functions as they evolve.

Use case 2: Testing complex data

If a unit tests contains many assert statements to check a complex data structure you can use regression tests instead.

Example: To test code which ingests data into a database one can use regression tests on textual database dumps.

Use case 3: Testing NumPy arrays or pandas data frames

If your code generates numerical results, such as NumPy arrays, pandas or polars data frames, you can use pytest-regtest to simply record such results and test them later, taking into account relative and absolute tolerances.

Example: A function creates a 10 x 10 matrix. Either you have to write 100 assert statements or you use summary statistics to test your result. In both cases, you may get little debugging information if a test fails.

Project details


Release history Release notifications | RSS feed

This version

2.5.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_regtest-2.5.1.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_regtest-2.5.1-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file pytest_regtest-2.5.1.tar.gz.

File metadata

  • Download URL: pytest_regtest-2.5.1.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for pytest_regtest-2.5.1.tar.gz
Algorithm Hash digest
SHA256 84f77f18fa70295377662de96d721d03b32d05509c53e1366aeec11dbed56ec0
MD5 1604f2c3b44b991c3eada1d747772ce8
BLAKE2b-256 1075528acd0411fbc7b67a5acda4f197a289c94e26fa4410b30b95135831b108

See more details on using hashes here.

File details

Details for the file pytest_regtest-2.5.1-py3-none-any.whl.

File metadata

  • Download URL: pytest_regtest-2.5.1-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for pytest_regtest-2.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8d94eb5dd08137cd4353250120ebb7b6e318d699721dca6bd8d5e436cb5bbe9f
MD5 d276d6bf7663d45acca0f18b76f87aee
BLAKE2b-256 770eef2ab0272c1ea6a908e51dcb3ea218a7de126debddd8f8b8b92a5791c5cb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page