Metadata-Version: 2.1
Name: snappiershot
Version: 1.0.1
Summary: Snapshot testing library.
Home-page: https://github.com/MORSECorp/snappiershot
Keywords: snapshot,testing
Author: Ben Bonenfant
Author-email: bonenfan5ben@gmail.com
Requires-Python: >=3.6.1,<4.0.0
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Testing :: Unit
Provides-Extra: pandas
Requires-Dist: importlib-metadata (>1.5.1); python_version < "3.8"
Requires-Dist: pandas (>=0.20.0); extra == "pandas"
Requires-Dist: pprint_ordered_sets (>=1.0.0,<2.0.0)
Requires-Dist: tomlkit (>=0.7.0,<0.8.0)
Project-URL: Repository, https://github.com/MORSECorp/snappiershot
Description-Content-Type: text/markdown

# SnappierShot
Add snapshot testing to your testing toolkit.

## Installation
```bash
$ pip install snappiershot
```

## Configuration
SnappierShot is following the [trend of packages](https://github.com/carlosperate/awesome-pyproject/)
in performing project-wide configuration through the pyproject.toml file established by
[PEP 518](https://www.python.org/dev/peps/pep-0518/).

Within the pyproject.toml file, all SnappierShot configuration can be found under the
`[tool.snappiershot]` heading.

### Example (with default values):
```toml
[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
```python
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
```python
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()
```

### Raises
Snappiershot also allows you to take a "snapshot" errors that are raised during
  the execution of a code block. This allows you to track how and when errors
  are reported more easily.

```python
def fallible_function():
    """ A function with an error state. """
    raise RuntimeError("An error occurred!")


def test_fallible_function(snapshot):
    """ Test that errors are being reported as expected"""
    # Arrange

    # Act & Assert
    with snapshot.raises(RuntimeError):
        fallible_function()
```

### 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](CONTRIBUTING.md)

