Skip to content

Commit d26d251

Browse files
committed
o close dataset before removing file, to fix PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'ugrid_exo_csne8.nc'
1 parent 0fbe58a commit d26d251

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

test/test_exodus.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def test_mixed_exodus():
5252
assert np.array_equal(ugrid_load_saved.node_lat.values, uxgrid.node_lat.values)
5353

5454
# Cleanup
55+
ugrid_load_saved._ds.close()
56+
exodus_load_saved._ds.close()
5557
os.remove("test_ugrid.nc")
5658
os.remove("test_exo.exo")
5759

test/test_grid.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ def test_grid_ugrid_exodus_roundtrip():
195195
rtol=ERROR_TOLERANCE
196196
)
197197

198+
# This might be need for windows "ermissionError: [WinError 32] -- file accessed by another process"
199+
reloaded_exodus._ds.close()
200+
reloaded_ugrid._ds.close()
201+
198202
# Clean up temporary test files
199203
for filepath in test_files:
200204
if os.path.exists(filepath):

test/test_scrip.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def test_to_xarray_ugrid():
6161
nt.assert_allclose(ux_grid.node_lat.values, reloaded_grid.node_lat.values)
6262

6363
# Cleanup
64+
reloaded_grid._ds.close()
6465
os.remove("scrip_ugrid_csne8.nc")
6566

6667
def test_standardized_dtype_and_fill():

test/test_ugrid.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def test_to_xarray_ugrid():
5858
nt.assert_allclose(ux_grid.node_lat.values, reloaded_grid.node_lat.values)
5959

6060
# Cleanup
61+
reloaded_grid._ds.close()
6162
os.remove("ugrid_exo_csne8.nc")
6263

6364
def test_standardized_dtype_and_fill():

0 commit comments

Comments
 (0)