Skip to content

Commit 190e962

Browse files
committed
Fix error on Windows
1 parent 2ee2207 commit 190e962

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

xarray/tests/test_backends_datatree.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
import netCDF4 as nc4
3434

3535

36+
ON_WINDOWS = sys.platform == "win32"
37+
38+
3639
class TestNetCDF4DataTree(_TestNetCDF4Data):
3740
@contextlib.contextmanager
3841
def open(self, path, **kwargs):
@@ -303,9 +306,12 @@ def test_compute_false(self, tmpdir, simple_datatree):
303306
original_dt = simple_datatree.chunk()
304307
result = original_dt.to_netcdf(filepath, engine=self.engine, compute=False)
305308

306-
with open_datatree(filepath, engine=self.engine) as in_progress_dt:
307-
assert in_progress_dt.isomorphic(original_dt)
308-
assert not in_progress_dt.equals(original_dt)
309+
if not ON_WINDOWS:
310+
# File at filepath is not closed until .compute() is called. On
311+
# Windows, this means we can't open it yet.
312+
with open_datatree(filepath, engine=self.engine) as in_progress_dt:
313+
assert in_progress_dt.isomorphic(original_dt)
314+
assert not in_progress_dt.equals(original_dt)
309315

310316
result.compute()
311317
with open_datatree(filepath, engine=self.engine) as written_dt:

0 commit comments

Comments
 (0)