MCPcopy
hub / github.com/pallets/click / test_wrap_text_visible_width

Function test_wrap_text_visible_width

tests/test_formatting.py:471–487  ·  view source on GitHub ↗

``wrap_text`` of styled input produces the same line layout as ``wrap_text`` of the ANSI-stripped input. ANSI escape bytes must not count toward the width budget, regardless of whether they appear in the body, in ``initial_indent``, or when a styled token has to be broken in the mid

(body, width, initial_indent)

Source from the content-addressed store, hash-verified

469 ],
470)
471def test_wrap_text_visible_width(body, width, initial_indent):
472 """``wrap_text`` of styled input produces the same line layout as
473 ``wrap_text`` of the ANSI-stripped input.
474
475 ANSI escape bytes must not count toward the width budget, regardless
476 of whether they appear in the body, in ``initial_indent``, or when a
477 styled token has to be broken in the middle.
478 """
479 styled = click.formatting.wrap_text(
480 body, width=width, initial_indent=initial_indent
481 )
482 plain = click.formatting.wrap_text(
483 strip_ansi(body), width=width, initial_indent=strip_ansi(initial_indent)
484 )
485
486 styled_visible = [strip_ansi(line) for line in styled.splitlines()]
487 assert styled_visible == plain.splitlines()
488
489
490def test_write_usage_styled_prefix_keeps_options_on_one_line():

Callers

nothing calls this directly

Calls 1

strip_ansiFunction · 0.90

Tested by

no test coverage detected