Snapshot testing library.
Project description
SnappierShot
Add snapshot testing to your testing toolkit.
Installation
$ pip install snappiershot
Configuration
Snappier shot is following the trend of packages in performing project-wide configuration through the pyproject.toml file established by PEP 518.
Within the pyproject.toml file, all snappiershot configuration can be found under the
[tool.snappiershot]
heading.
Example (with default values):
[tool.snappiershot]
file_format = "json"
float_absolute_tolerance = 1e-6
float_relative_tolerance = 0.001
full_diff = false
json_indentation = 4
Usage
SnappierShot allows you to take a "snapshot" of data the first time that a test
is run, and stores it nearby in a .snapshots
directory. Then, for all
subsequent times that test is run, the data is assert to "match" the original
data.
Pytest Example
def test_something(snapshot):
""" Test that something works as expected"""
# Arrange
x = 1
y = 2
# Act
result = x + y
# Assert
snapshot.assert_match(result)
No Test Runner Example
from snappiershot import Snapshot
def test_something():
""" Test that something works as expected"""
# Arrange
x = 1
y = 2
# Act
result = x + y
# Assert
with Snapshot() as snapshot
snapshot.assert_match(result)
test_something()
Support Types:
- Primitives (
bool
,int
,float
,None
,str
) - Numerics (
complex
) - Collections (
lists
,tuples
,sets
) - Dictionaries
- Classes (with an underlying
__dict__
) - Classes with custom encoding (by defining a
__snapshot__
method).
Contributing
See CONTRIBUTING.md
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
snappiershot-0.1.1.tar.gz
(24.7 kB
view hashes)
Built Distribution
Close
Hashes for snappiershot-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94699aeed5c706700c976a9291a9f616e063096fb1b0e2cee2948504617bd499 |
|
MD5 | 8883db1b8f90f36699ee4f20276fbc94 |
|
BLAKE2b-256 | eb7c7dd23edf21dbaa0ca775548b526fef64811db059ab94a883b770727ad2db |