``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)
| 469 | ], |
| 470 | ) |
| 471 | def 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 | |
| 490 | def test_write_usage_styled_prefix_keeps_options_on_one_line(): |
nothing calls this directly
no test coverage detected