diff --git a/xarray/core/formatting_html.py b/xarray/core/formatting_html.py
index 9730a0a1745..5c2d2210ebd 100644
--- a/xarray/core/formatting_html.py
+++ b/xarray/core/formatting_html.py
@@ -39,7 +39,7 @@ def format_dims(dims, coord_names):
}
dims_li = "".join(
- f"
")
assert "xarray.Variable" in html
+
+
+def test_repr_of_nonstr_dataset(dataset):
+ ds = dataset.copy()
+ ds.attrs[1] = "Test value"
+ ds[2] = ds["tmin"]
+ formatted = fh.dataset_repr(ds)
+ assert "
1 :Test value" in formatted
+ assert "
2" in formatted
+
+
+def test_repr_of_nonstr_dataarray(dataarray):
+ da = dataarray.rename(dim_0=15)
+ da.attrs[1] = "value"
+ formatted = fh.array_repr(da)
+ assert "
1 :value" in formatted
+ assert "15: 4" in formatted
+
+
+def test_nonstr_variable_repr_html():
+ v = xr.Variable(["time", 10], [[1, 2, 3], [4, 5, 6]], {22: "bar"})
+ assert hasattr(v, "_repr_html_")
+ with xr.set_options(display_style="html"):
+ html = v._repr_html_().strip()
+ assert "22 :bar" in html
+ assert "10: 3" in html