pytest plugin for snapshot regression testing
Project description
The full documentatin 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
`pyteset-regtest` offers some functionalities which are tailored
for `NumPy`, `pandas` and `polars`. These depencies are not
installed if you install `pytest-regtest`. In case you are using
e.g. `NumPy` snapshots, we assume that your productive code (the
code under test) uses `NumPy` and thus should be part of the setup
of your project.
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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file pytest_regtest-2.3.1-py2.py3-none-any.whl
.
File metadata
- Download URL: pytest_regtest-2.3.1-py2.py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9954c80cdc70ab6cb467853c6dd6e62bdd94008ae1d95279b4b68da4906a9ca5 |
|
MD5 | 2b7f4244bc886deb2fa542250d3a67e5 |
|
BLAKE2b-256 | 13cb284241aaefae16ad88811e04d9e5f1ad2b3cf62cfe01e8b65bccbf6e87e5 |