Skip to content

Commit c57b3ba

Browse files
authored
fix: do not delete partially written snapshot (#20)
1 parent de60716 commit c57b3ba

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/syrupy/session.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ def add_visited_snapshots(self, snapshots: SnapshotFiles):
127127

128128
def remove_unused_snapshots(self):
129129
for snapshot_file, unused_snapshots in self.unused_snapshots.items():
130-
if self.discovered_snapshots[snapshot_file] == unused_snapshots:
130+
all_discovered_unused = (
131+
unused_snapshots == self.discovered_snapshots[snapshot_file]
132+
)
133+
no_snapshot_written = not self.written_snapshots.get(snapshot_file)
134+
if all_discovered_unused and no_snapshot_written:
131135
os.remove(snapshot_file)
132136
continue
133137
snapshot_assertion, *_ = self._assertions[snapshot_file].values()

0 commit comments

Comments
 (0)