Skip to content

Commit 7288eb2

Browse files
committed
Add dask test
1 parent c2786eb commit 7288eb2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

xarray/tests/test_formatting.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
import xarray as xr
1010
from xarray.core import formatting
1111

12-
from . import requires_netCDF4
12+
from . import (
13+
requires_netCDF4,
14+
requires_dask,
15+
)
1316

1417

1518
class TestFormatting:
@@ -413,6 +416,7 @@ def test_array_repr_variable(self) -> None:
413416
with xr.set_options(display_expand_data=False):
414417
formatting.array_repr(var)
415418

419+
@requires_dask
416420
def test_array_scalar_format(self) -> None:
417421
var = xr.DataArray(0)
418422
assert var.__format__("") == "0"
@@ -425,6 +429,12 @@ def test_array_scalar_format(self) -> None:
425429
var.__format__(".2f")
426430
assert "unsupported format string passed to" in str(excinfo.value)
427431

432+
# also check for dask
433+
var = var.chunk(chunks={'dim_0': 1})
434+
assert var.__format__("") == "[0.1 0.2]"
435+
with pytest.raises(TypeError) as excinfo:
436+
var.__format__(".2f")
437+
assert "unsupported format string passed to" in str(excinfo.value)
428438

429439
def test_inline_variable_array_repr_custom_repr() -> None:
430440
class CustomArray:

0 commit comments

Comments
 (0)