tests.test_layout module

Tests for click_extra.layout: measuring a line and composing one.

tests.test_layout.test_center_in_rule_draws_an_unbroken_line_for_no_label(label)[source]

Naming nothing draws a divider, not a frame around an empty middle.

tests.test_layout.test_center_in_rule_measures_a_styled_label_unstyled()[source]

A label’s escapes occupy no cell, so they must not shorten the rule.

tests.test_layout.test_center_in_rule_paints_the_rule_and_leaves_the_label_alone()[source]

The rule recedes by default, and a caller’s own label styling survives.

tests.test_layout.test_fit_columns_floors_at_nothing_by_default()[source]

The floor belongs to whoever lays the text out, not to the measure.

tests.test_layout.test_cell_width_discounts_what_a_terminal_draws_nowhere(text, cells)[source]

Escapes and hyperlinks measure nothing, and a tab measures to its stop.

wcwidth.wcswidth refuses any string carrying a control character and answers -1: a measure built on it falls back to the character count of a styled string, 16 for a red apricot the terminal draws in 7.

tests.test_layout.test_cell_width_is_never_negative()[source]

A control character measures what a terminal advances by, never -1.

tests.test_layout.test_pad_to_measures_the_text_a_terminal_draws()[source]

str.ljust counts escapes it cannot see, so a styled line pads short.

tests.test_layout.test_pad_to_closes_a_style_before_the_blanks()[source]

A background left open would otherwise bleed across the gap.

tests.test_layout.test_pad_to_leaves_text_already_wide_enough_alone()[source]

Nothing to pad, nothing added, reset included.

tests.test_layout.test_number_lines_aligns_on_the_digits_it_is_given()[source]

digits widens the gutter, and never cuts the widest number short.

tests.test_layout.test_number_frames_gives_every_frame_the_gutter_of_the_tallest()[source]

Each frame counts its own rows, at the width its tallest sibling needs.