Skip to content

Commit

Permalink
Fail when new snapshots are added and not updated
Browse files Browse the repository at this point in the history
See upstream:

syrusakbary#73

If not configured to update the tests, fail when new tests are added.
  • Loading branch information
noahp committed Sep 12, 2022
1 parent 48528b7 commit 0beff0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
> **NOTE:** this is a fork to fix https://github.com/syrusakbary/snapshottest/issues/73
# SnapshotTest [![travis][travis-image]][travis-url] [![pypi][pypi-image]][pypi-url]

[travis-image]: https://img.shields.io/travis/syrusakbary/snapshottest.svg?style=flat
Expand Down Expand Up @@ -74,7 +76,7 @@ Check the [Django example](https://github.com/syrusakbary/snapshottest/tree/mast

## Disabling terminal colors

Set the environment variable `ANSI_COLORS_DISABLED` (to any value), e.g.
Set the environment variable `ANSI_COLORS_DISABLED` (to any value), e.g.

ANSI_COLORS_DISABLED=1 pytest

Expand All @@ -88,7 +90,7 @@ make develop
```

After developing, ensure your code is formatted properly by running:

```sh
make format-fix
```
Expand All @@ -101,7 +103,7 @@ make lint
make test
```

To test locally on all supported Python versions, you can use
To test locally on all supported Python versions, you can use
[tox](https://tox.readthedocs.io/):

```sh
Expand Down
5 changes: 4 additions & 1 deletion snapshottest/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ def assert_match(self, value, name=""):
try:
prev_snapshot = self.module[self.test_name]
except SnapshotNotFound:
self.store(value) # first time this test has been seen
if self.update:
self.store(value) # first time this test has been seen
else:
raise
else:
try:
self.assert_value_matches_snapshot(value, prev_snapshot)
Expand Down

0 comments on commit 0beff0d

Please sign in to comment.