def test_cftimeindex_repr_formatting_width(periods, display_width):
    """Test that cftimeindex is sensitive to OPTIONS['display_width']."""
    index = xr.date_range(start="2000", periods=periods, use_cftime=True)
    len_intro_str = len("CFTimeIndex(")
    with xr.set_options(display_width=display_width):
        repr_str = index.__repr__()
        splitted = repr_str.split("\n")
        for i, s in enumerate(splitted):
            # check that lines not longer than OPTIONS['display_width']
            assert len(s) <= display_width, f"{len(s)} {s} {display_width}"
            if i > 0:
                # check for initial spaces
                assert s[:len_intro_str] == " " * len_intro_str
Test that cftimeindex is sensitive to OPTIONS['display_width'].
xarray/tests/test_cftimeindex.py