tests.test_styling moduleΒΆ

Tests for click_extra.styling.Style extras.

tests.test_styling.test_hex_fg_converts_to_rgb_tuple(hex_str, expected_rgb)[source]ΒΆ
tests.test_styling.test_hex_bg_converts_to_rgb_tuple()[source]ΒΆ
tests.test_styling.test_hex_invalid_raises(hex_str)[source]ΒΆ
tests.test_styling.test_named_color_string_passes_through()[source]ΒΆ

Plain named-color strings must not be touched by the hex shorthand.

tests.test_styling.test_or_right_operand_wins_on_conflicts()[source]ΒΆ
tests.test_styling.test_or_returns_subclass_instance()[source]ΒΆ
tests.test_styling.test_or_with_cloup_style_promotes_to_subclass()[source]ΒΆ
tests.test_styling.test_ror_with_cloup_left_operand()[source]ΒΆ

cloup_style | my_style is reached via __ror__.

tests.test_styling.test_or_with_non_style_returns_notimplemented()[source]ΒΆ

Style | int falls through to int.__ror__ and raises TypeError.

tests.test_styling.test_cascade_fills_unset_fields_from_base()[source]ΒΆ
tests.test_styling.test_cascade_keeps_subclass_identity()[source]ΒΆ
tests.test_styling.test_cascade_with_non_style_raises()[source]ΒΆ
tests.test_styling.test_to_dict_omits_unset_fields()[source]ΒΆ
tests.test_styling.test_to_dict_serializes_rgb_as_hex()[source]ΒΆ
tests.test_styling.test_to_dict_omits_none_only()[source]ΒΆ

False boolean attributes are kept; only None is filtered out.

tests.test_styling.test_from_dict_round_trip()[source]ΒΆ
tests.test_styling.test_from_dict_accepts_hex_or_rgb()[source]ΒΆ

Both hex strings and RGB tuples work as input.

tests.test_styling.test_str_returns_styled_sample()[source]ΒΆ
tests.test_styling.test_str_no_styling_has_no_color_codes()[source]ΒΆ

Style with no fields set produces only click’s bare reset suffix.

tests.test_styling.test_repr_compact_named_color()[source]ΒΆ
tests.test_styling.test_repr_compact_rgb_to_hex()[source]ΒΆ
tests.test_styling.test_repr_palette_index_zero()[source]ΒΆ

Index 0 is falsy but set: it must survive the is not None guards.

tests.test_styling.test_repr_empty_style()[source]ΒΆ
tests.test_styling.test_repr_multiple_attrs()[source]ΒΆ
tests.test_styling.test_to_css_basic()[source]ΒΆ
tests.test_styling.test_to_css_named_color_passes_through()[source]ΒΆ
tests.test_styling.test_to_css_palette_index_zero()[source]ΒΆ

Palette index 0 is falsy but set, and resolves to ANSI black.

tests.test_styling.test_to_css_bright_named_color_resolves_to_rgb()[source]ΒΆ

Bright ANSI colors aren’t valid CSS keywords: convert to RGB.

tests.test_styling.test_to_css_text_decorations_combine()[source]ΒΆ
tests.test_styling.test_to_css_dim_emits_opacity()[source]ΒΆ
tests.test_styling.test_to_css_empty_style_returns_empty_string()[source]ΒΆ
tests.test_styling.test_from_ansi_parses_codes(escape, expected)[source]ΒΆ
tests.test_styling.test_from_ansi_full_styled_string_round_trip()[source]ΒΆ

Parsing a style’s complete output (trailing reset included) recovers it.

tests.test_styling.test_from_ansi_round_trip_through_call()[source]ΒΆ

A Style can be parsed back from its own ANSI output.

tests.test_styling.test_from_ansi_invalid_raises()[source]ΒΆ
tests.test_styling.test_contrast_ratio_white_on_black_is_max()[source]ΒΆ
tests.test_styling.test_contrast_ratio_identical_colors_is_one()[source]ΒΆ
tests.test_styling.test_contrast_ratio_is_symmetric()[source]ΒΆ
tests.test_styling.test_contrast_ratio_meets_wcag_aa_for_dracula_default()[source]ΒΆ

Dracula’s default fg/bg pair clears WCAG AA (4.5).

tests.test_styling.test_contrast_ratio_requires_both_fgs()[source]ΒΆ
tests.test_styling.test_eq_survives_a_call()[source]ΒΆ

Calling a style leaves its equality and hash untouched.

tests.test_styling.test_eq_with_cloup_style(style, twin)[source]ΒΆ

A click-extra Style equals the cloup.Style carrying its fields, both ways.

tests.test_styling.test_eq_with_non_style()[source]ΒΆ

Comparing with anything else defers to the other operand.

tests.test_styling.test_supports_truecolor(monkeypatch, colorterm, term, expected)[source]ΒΆ
tests.test_styling.test_style_call_keeps_24bit_on_truecolor(monkeypatch)[source]ΒΆ

An RGB color emits a 24-bit sequence when the terminal supports truecolor.

tests.test_styling.test_style_call_quantizes_without_truecolor(monkeypatch)[source]ΒΆ

An RGB color downsamples to the nearest 256-index without truecolor.

tests.test_styling.test_style_call_leaves_named_and_indexed_colors(monkeypatch, colorterm)[source]ΒΆ

Named and palette-index colors never quantize, regardless of depth.

tests.test_styling.test_style_call_survives_depth_flip(monkeypatch)[source]ΒΆ

The same style renders correctly when truecolor flips between calls.

Quantizing works on a transient copy, so the shared (often singleton) theme style keeps its 24-bit colors for the next call.

tests.test_styling.test_style_call_palette_index_zero(style, expected)[source]ΒΆ

Rendering palette index 0 must emit its escape code, not drop it.

tests.test_styling.test_style_call_empty_string_color_rejected(style)[source]ΒΆ

Click validates colors at render time and rejects empty strings.

Click 8.5 raises TypeError, its development branch ValueError.

tests.test_styling.test_int_enum_color_round_trips_by_value()[source]ΒΆ

A palette index held by an IntEnum serializes as the index it is.

tests.test_styling.test_split_ansi(text, expected)[source]ΒΆ
tests.test_styling.test_split_ansi_empty_string()[source]ΒΆ
tests.test_styling.test_split_ansi_preserves_text()[source]ΒΆ

Concatenated run texts equal the ANSI-stripped input.

tests.test_styling.test_render_ansi_passthrough_unstyled()[source]ΒΆ
tests.test_styling.test_render_ansi_wraps_styled_runs()[source]ΒΆ
tests.test_styling.test_render_ansi_splits_runs_at_newlines()[source]ΒΆ

No markup wrapper ever crosses a line boundary.

tests.test_styling.test_wrap_ansi_matches_textwrap_on_plain_text()[source]ΒΆ

Unstyled input defers entirely to textwrap.

tests.test_styling.test_wrap_ansi_breaks_on_visible_width()[source]ΒΆ

A styled string breaks exactly where its plain counterpart does.

textwrap alone counts the escape bytes toward the line length, which would break a styled string several words early.

tests.test_styling.test_wrap_ansi_closes_styling_on_every_line()[source]ΒΆ

No escape sequence crosses a line boundary.

tests.test_styling.test_wrap_ansi_keeps_styling_on_its_own_words()[source]ΒΆ

Each run keeps its style once the text is split across lines.

tests.test_styling.test_wrap_ansi_edge_cases(text, width, expected)[source]ΒΆ
tests.test_styling.test_ansi_converters(converter, text, expected)[source]ΒΆ