From 35b4aead8eb91c867a4e27394e1e9f3d74f369b5 Mon Sep 17 00:00:00 2001 From: Noah Pendleton <2538614+noahp@users.noreply.github.com> Date: Mon, 12 Sep 2022 10:59:51 -0400 Subject: [PATCH] Fail when new snapshots are added and not updated See upstream: https://github.com/syrusakbary/snapshottest/issues/73 If not configured to update the tests, fail when new tests are added. --- snapshottest/module.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/snapshottest/module.py b/snapshottest/module.py index e31b46c..ed8394a 100644 --- a/snapshottest/module.py +++ b/snapshottest/module.py @@ -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)