Skip to content

Commit 7f71e40

Browse files
authored
Fix dask-distributed tests (#1293)
* Fix dask-distributed tests This should resolve the failing tests on master. Fixes #1292 * Use a context manager to ensure file is closed * Allow clean-up failure on Window
1 parent 5e50c0d commit 7f71e40

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

xarray/tests/test_distributed.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
da = pytest.importorskip('dask.array')
77
from distributed.utils_test import cluster, loop
88

9-
from xarray.tests.test_backends import create_tmp_file
9+
from xarray.tests.test_backends import create_tmp_file, ON_WINDOWS
1010
from xarray.tests.test_dataset import create_test_data
1111

1212
from . import assert_allclose, has_scipy, has_netCDF4, has_h5netcdf
@@ -24,11 +24,11 @@
2424
@pytest.mark.parametrize('engine', ENGINES)
2525
def test_dask_distributed_integration_test(loop, engine):
2626
with cluster() as (s, _):
27-
with distributed.Client(('127.0.0.1', s['port']), loop=loop):
27+
with distributed.Client(s['address'], loop=loop):
2828
original = create_test_data()
29-
with create_tmp_file() as filename:
29+
with create_tmp_file(allow_cleanup_failure=ON_WINDOWS) as filename:
3030
original.to_netcdf(filename, engine=engine)
31-
restored = xr.open_dataset(filename, chunks=3, engine=engine)
32-
assert isinstance(restored.var1.data, da.Array)
33-
computed = restored.compute()
34-
assert_allclose(original, computed)
31+
with xr.open_dataset(filename, chunks=3, engine=engine) as restored:
32+
assert isinstance(restored.var1.data, da.Array)
33+
computed = restored.compute()
34+
assert_allclose(original, computed)

0 commit comments

Comments
 (0)