Skip to content

Commit

Permalink
fix: do not delete partially written snapshot (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamogbz authored Dec 7, 2019
1 parent de60716 commit c57b3ba
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/syrupy/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ def add_visited_snapshots(self, snapshots: SnapshotFiles):

def remove_unused_snapshots(self):
for snapshot_file, unused_snapshots in self.unused_snapshots.items():
if self.discovered_snapshots[snapshot_file] == unused_snapshots:
all_discovered_unused = (
unused_snapshots == self.discovered_snapshots[snapshot_file]
)
no_snapshot_written = not self.written_snapshots.get(snapshot_file)
if all_discovered_unused and no_snapshot_written:
os.remove(snapshot_file)
continue
snapshot_assertion, *_ = self._assertions[snapshot_file].values()
Expand Down

0 comments on commit c57b3ba

Please sign in to comment.