MCPcopy
hub / github.com/pydata/xarray / test_cftimeindex_repr_formatting_width

Function test_cftimeindex_repr_formatting_width

xarray/tests/test_cftimeindex.py:1173–1185  ·  view source on GitHub ↗

Test that cftimeindex is sensitive to OPTIONS['display_width'].

(periods, display_width)

Source from the content-addressed store, hash-verified

1171@pytest.mark.parametrize("display_width", [40, 80, 100])
1172@pytest.mark.parametrize("periods", [2, 3, 4, 100, 101])
1173def test_cftimeindex_repr_formatting_width(periods, display_width):
1174 """Test that cftimeindex is sensitive to OPTIONS['display_width']."""
1175 index = xr.date_range(start="2000", periods=periods, use_cftime=True)
1176 len_intro_str = len("CFTimeIndex(")
1177 with xr.set_options(display_width=display_width):
1178 repr_str = index.__repr__()
1179 splitted = repr_str.split("\n")
1180 for i, s in enumerate(splitted):
1181 # check that lines not longer than OPTIONS['display_width']
1182 assert len(s) <= display_width, f"{len(s)} {s} {display_width}"
1183 if i > 0:
1184 # check for initial spaces
1185 assert s[:len_intro_str] == " " * len_intro_str
1186
1187
1188@requires_cftime

Callers

nothing calls this directly

Calls 2

splitMethod · 0.80
__repr__Method · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…