Metadata-Version: 2.4
Name: snaptol
Version: 0.0.2
Summary: A Python tool for snapshot testing with numerical tolerance on floating point numbers
Author: Ava Dean
License-Expression: MIT
Keywords: snapshot,testing,numerical tolerance,floating point error
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=2.0.0
Requires-Dist: pytest>=8.4.1
Provides-Extra: docs
Requires-Dist: myst-nb>=1.3.0; extra == "docs"
Requires-Dist: sphinx>=8.2.3; extra == "docs"
Requires-Dist: sphinx-autodoc-typehints>=3.2.0; extra == "docs"
Requires-Dist: sphinx-book-theme>=1.1.4; extra == "docs"
Provides-Extra: tests
Requires-Dist: pytest>=8.4.1; extra == "tests"
Provides-Extra: lint
Requires-Dist: ruff>=0.12.0; extra == "lint"
Dynamic: license-file

# snaptol

A Python tool for snapshot testing with numerical tolerance on floating point numbers.

## Installation

Use the package manager [pip](https://pip.pypa.io/en/stable/) to install snaptol.

```bash
pip install snaptol
```

## Usage

### Normal usage

In a test file, add the snapshot fixture, `snaptolshot`,
```python
def test_something(snaptolshot):
    result = compute_something()
    assert snaptolshot == result
```
When `pytest` runs, it will compare the result to the snapshot stored in file.

To provide a tolerance, pass it as an argument to the fixture,
```python
def test_something(snaptolshot):
    result = compute_something()
    assert snaptolshot(rtol=1e-05, atol=1e-08) == result
```

Alternatively, use the `match` method,
```python
def test_something(snaptolshot):
    result = compute_something()
    assert snaptolshot.match(rtol=1e-05, atol=1e-08) == result
```

### Updating snapshots

On initial pass and subsequent changes to the test, run `pytest` with the `--snapshot-update` flag,
```python
pytest --snapshot-update
```
This will not perform the comparison between snapshot and result, but rather update the snapshot file with the current result.

## Contributing

Pull requests are welcome. For major changes, please open an issue first
to discuss what you would like to change.

Please make sure to update tests as appropriate.

## License

[MIT](https://choosealicense.com/licenses/mit/)
