tests.test_styling moduleΒΆ
Tests for click_extra.styling.Style extras.
- 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_ror_with_cloup_left_operand()[source]ΒΆ
cloup_style | my_styleis reached via__ror__.
- tests.test_styling.test_or_with_non_style_returns_notimplemented()[source]ΒΆ
Style | int falls through to
int.__ror__and raisesTypeError.
- tests.test_styling.test_to_dict_omits_none_only()[source]ΒΆ
Falseboolean attributes are kept; onlyNoneis filtered out.
- 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_no_styling_has_no_color_codes()[source]ΒΆ
Style with no fields set produces only clickβs bare reset suffix.
- tests.test_styling.test_repr_palette_index_zero()[source]ΒΆ
Index
0is falsy but set: it must survive theis not Noneguards.
- tests.test_styling.test_to_css_palette_index_zero()[source]ΒΆ
Palette index
0is 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_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_contrast_ratio_meets_wcag_aa_for_dracula_default()[source]ΒΆ
Draculaβs default fg/bg pair clears WCAG AA (4.5).
- 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_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
0must 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 branchValueError.
- tests.test_styling.test_int_enum_color_round_trips_by_value()[source]ΒΆ
A palette index held by an
IntEnumserializes as the index it is.
- tests.test_styling.test_split_ansi_preserves_text()[source]ΒΆ
Concatenated run texts equal the ANSI-stripped input.
- 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.
textwrapalone 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.