diff --git a/xarray/tests/test_dask.py b/xarray/tests/test_dask.py index fdb2ff715dd..0244c7ec8af 100644 --- a/xarray/tests/test_dask.py +++ b/xarray/tests/test_dask.py @@ -4,6 +4,8 @@ import pickle from textwrap import dedent + +from distutils.version import LooseVersion import numpy as np import pandas as pd import pytest @@ -12,13 +14,12 @@ from xarray import Variable, DataArray, Dataset import xarray.ufuncs as xu from xarray.core.pycompat import suppress -from . import TestCase, requires_dask +from . import TestCase from xarray.tests import mock -with suppress(ImportError): - import dask - import dask.array as da +dask = pytest.importorskip('dask') +import dask.array as da class DaskTestCase(TestCase): @@ -44,7 +45,6 @@ def assertLazyAnd(self, expected, actual, test): assert False -@requires_dask class TestVariable(DaskTestCase): def assertLazyAndIdentical(self, expected, actual): self.assertLazyAnd(expected, actual, self.assertVariableIdentical) @@ -206,7 +206,6 @@ def test_bivariate_ufunc(self): self.assertLazyAndAllClose(np.maximum(u, 0), xu.maximum(0, v)) -@requires_dask class TestDataArrayAndDataset(DaskTestCase): def assertLazyAndIdentical(self, expected, actual): self.assertLazyAnd(expected, actual, self.assertDataArrayIdentical) @@ -252,6 +251,10 @@ def test_lazy_array(self): self.assertLazyAndAllClose(u, actual) def test_groupby(self): + if LooseVersion(dask.__version__) == LooseVersion('0.15.3'): + pytest.xfail('upstream bug in dask: ' + 'https://github.com/dask/dask/issues/2718') + u = self.eager_array v = self.lazy_array @@ -473,7 +476,6 @@ def test_from_dask_variable(self): self.assertLazyAndIdentical(self.lazy_array, a) -@requires_dask @pytest.mark.parametrize("method", ['load', 'compute']) def test_dask_kwargs_variable(method): x = Variable('y', da.from_array(np.arange(3), chunks=(2,))) @@ -484,7 +486,6 @@ def test_dask_kwargs_variable(method): mock_compute.assert_called_with(foo='bar') -@requires_dask @pytest.mark.parametrize("method", ['load', 'compute', 'persist']) def test_dask_kwargs_dataarray(method): data = da.from_array(np.arange(3), chunks=(2,)) @@ -499,7 +500,6 @@ def test_dask_kwargs_dataarray(method): mock_func.assert_called_with(data, foo='bar') -@requires_dask @pytest.mark.parametrize("method", ['load', 'compute', 'persist']) def test_dask_kwargs_dataset(method): data = da.from_array(np.arange(3), chunks=(2,))