Skip to content

Commit

Permalink
Add test for writing unbacked data over existing files
Browse files Browse the repository at this point in the history
  • Loading branch information
aeisenbarth committed Aug 29, 2023
1 parent f58c4f4 commit a4f69e0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/io/test_readwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,18 @@ def test_replace_transformation_on_disk_non_raster(self, shapes, points):
t1 = get_transformation(SpatialData.read(f).__getattribute__(k)[elem_name])
assert type(t1) == Scale

def test_overwrite_files_without_backed_data(self, full_sdata):
with tempfile.TemporaryDirectory() as tmpdir:
f = os.path.join(tmpdir, "data.zarr")
old_data = SpatialData()
old_data.write(f)
# Since not backed, no risk of overwriting backing data. Should not raise.
try:
full_sdata.write(f, overwrite=True)
except Exception as e:
assert "The file path specified is the same as the one used for backing" not in str(e)
raise # Let other unexpected exceptions bubble up

def test_overwrite_files_with_backed_data(self, full_sdata):
# addressing https://github.com/scverse/spatialdata/issues/137
with tempfile.TemporaryDirectory() as tmpdir:
Expand Down

0 comments on commit a4f69e0

Please sign in to comment.