A Python tool for snapshot testing with numerical tolerance on floating point numbers
Project description
snaptol
A Python tool for snapshot testing with numerical tolerance on floating point numbers.
Installation
Use the package manager pip to install snaptol.
pip install snaptol
Usage
Normal usage
In a test file, add the snapshot fixture, snaptolshot,
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,
def test_something(snaptolshot):
result = compute_something()
assert snaptolshot(rtol=1e-05, atol=1e-08) == result
Alternatively, use the match method,
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,
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file snaptol-0.0.2.tar.gz.
File metadata
- Download URL: snaptol-0.0.2.tar.gz
- Upload date:
- Size: 96.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50b1a3ac95e1162d063f34639688360a52f439fd1bbf0f6b46ad6ec14da96a6c
|
|
| MD5 |
1625ccf733edba8e353079af86dac1f6
|
|
| BLAKE2b-256 |
9487177dd9fbf9e7d8ebd1150e96eb42a58241192e042b7ecb2d77979ca61f54
|
Provenance
The following attestation bundles were made for snaptol-0.0.2.tar.gz:
Publisher:
release.yml on PlasmaFAIR/snaptol
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
snaptol-0.0.2.tar.gz -
Subject digest:
50b1a3ac95e1162d063f34639688360a52f439fd1bbf0f6b46ad6ec14da96a6c - Sigstore transparency entry: 757430676
- Sigstore integration time:
-
Permalink:
PlasmaFAIR/snaptol@1b1b6fd78d5eced50b8a84b74c0a089b4391b163 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/PlasmaFAIR
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1b1b6fd78d5eced50b8a84b74c0a089b4391b163 -
Trigger Event:
push
-
Statement type:
File details
Details for the file snaptol-0.0.2-py3-none-any.whl.
File metadata
- Download URL: snaptol-0.0.2-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d224c2de79762f3294d0e9640545d8746103c10aa706a3e217c9eb19524f498c
|
|
| MD5 |
d9ede7db912c7bdb635ef58fd64e204a
|
|
| BLAKE2b-256 |
9006997de573f5b17763729943fe793f6dff74ecca6e0f644256b7d20175cee2
|
Provenance
The following attestation bundles were made for snaptol-0.0.2-py3-none-any.whl:
Publisher:
release.yml on PlasmaFAIR/snaptol
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
snaptol-0.0.2-py3-none-any.whl -
Subject digest:
d224c2de79762f3294d0e9640545d8746103c10aa706a3e217c9eb19524f498c - Sigstore transparency entry: 757430693
- Sigstore integration time:
-
Permalink:
PlasmaFAIR/snaptol@1b1b6fd78d5eced50b8a84b74c0a089b4391b163 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/PlasmaFAIR
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1b1b6fd78d5eced50b8a84b74c0a089b4391b163 -
Trigger Event:
push
-
Statement type: