tests.test_spinner module

tests.test_spinner.test_spinner_exported_from_root()[source]
tests.test_spinner.test_default_stream_is_stderr()[source]
tests.test_spinner.test_explicit_stream_is_honored()[source]
tests.test_spinner.test_can_draw(live, stream, expected)[source]
tests.test_spinner.test_noop_on_non_tty_stream()[source]

A non-interactive stream produces no output and spawns no thread.

tests.test_spinner.test_delay_suppresses_quick_calls()[source]

A call shorter than the delay never draws anything.

tests.test_spinner.test_draws_and_cleans_up_when_enabled()[source]
tests.test_spinner.test_shown_false_when_not_drawn()[source]

shown stays False whenever no frame reaches the terminal.

tests.test_spinner.test_shown_true_after_drawing()[source]

shown flips to True once a frame is drawn, and stays True after stop.

tests.test_spinner.test_label_can_change_mid_spin()[source]
tests.test_spinner.test_hide_cursor_disabled()[source]
tests.test_spinner.test_ascii_frames()[source]
tests.test_spinner.test_stop_is_idempotent_and_safe_before_start()[source]
tests.test_spinner.test_suspend_and_resume()[source]

A spinner restarts cleanly after a stop, without re-using a dead thread.

tests.test_spinner.test_rotation_direction(reverse)[source]

Frames cycle forwards by default and backwards when reverse=True.

tests.test_spinner.test_beep_rings_bell_on_stop_when_enabled()[source]
tests.test_spinner.test_beep_silent_when_disabled()[source]

A disabled spinner never beeps, even with beep=True.

tests.test_spinner.test_echo_prints_above_running_spinner()[source]
tests.test_spinner.test_echo_degrades_to_plain_write_when_disabled()[source]

Off a TTY the message is still emitted, just without control codes.

tests.test_spinner.test_progress_option_is_a_default_option()[source]

ProgressOption ships in the default option set of every extra command.

tests.test_spinner.test_progress_option_resolution(invoke, args, expected)[source]

ctx.meta[PROGRESS] follows –progress and –accessible, never color.

tests.test_spinner.test_standalone_progress_option(invoke, cmd_decorator, option_decorator)[source]
tests.test_spinner.test_auto_spinner_follows_progress_flag(invoke, args, draws)[source]

A live="auto" spinner stays still under --no-progress and --accessible, even on a terminal, with no wiring in the command.

tests.test_spinner.test_spinner_stop_leaves_a_stalled_drawing_thread_behind(monkeypatch)[source]

stop() gives up on a drawing thread stuck in a write after the grace, instead of hanging the Ctrl+C that asked for the stop.

tests.test_spinner.SPINNING_SCRIPT = '\nimport sys\nimport time\n\nfrom click_extra import Spinner\n\nSpinner("Brewing tea", stream=sys.stdout, live="always", interval=0.02).start()\ntime.sleep(30)\n'

A process spinning until something kills it.

tests.test_spinner.test_sigterm_shows_the_cursor_again(tmp_path)[source]

A spinner killed by SIGTERM leaves its terminal with the cursor shown, and the process still dies by SIGTERM.

tests.test_spinner.test_dumb_terminal_disables_spinner(monkeypatch, term)[source]

A cursor-less terminal self-disables the spinner even on a TTY.

tests.test_spinner.test_live_always_overrides_dumb_terminal(monkeypatch)[source]

An explicit live="always" wins over the TERM=dumb auto-detection.

tests.test_spinner.test_decorator_runs_function_inside_spinner()[source]

@spinner animates while the wrapped function runs and returns its result.

tests.test_spinner.test_bare_decorator_without_parentheses()[source]

@Spinner with no parentheses wraps the function with default settings.

tests.test_spinner.test_resolve_color_enabled(monkeypatch, env, stream_factory, expected)[source]

Color follows FORCE_COLOR / dumb TERM / NO_COLOR then TTY, with no context.

tests.test_spinner.test_color_applied_on_tty(monkeypatch)[source]
tests.test_spinner.test_color_stripped_but_spinner_still_spins_when_disabled(monkeypatch)[source]

NO_COLOR strips the spinner’s color but never stops it spinning.

tests.test_spinner.test_style_applied_to_spinner(monkeypatch)[source]
tests.test_spinner.test_invalid_style_raises()[source]
tests.test_spinner.test_style_alone_keeps_painting_the_line_as_one_run()[source]

Without a part style, style still wraps the whole line, byte for byte.

tests.test_spinner.test_part_styles_paint_their_own_part(options, glyph, label, timer)[source]

Each part carries its leading space and takes its own style over style.

The timer’s parentheses belong to its part, which is what a timer callable formatting only the duration cannot reach.

tests.test_spinner.test_color_off_strips_escapes_embedded_in_the_label(options)[source]

A label styled by hand renders plain when color is off, like any other.

tests.test_spinner.test_kept_line_paints_label_and_timer_with_part_styles(monkeypatch)[source]

ok() paints its label and timer with the part styles, when color is on.

tests.test_spinner.test_kept_line_strips_embedded_escapes_with_color_off()[source]

Off a TTY, ok() writes the label plain, embedded escapes included.

tests.test_spinner.test_invalid_part_style_raises(options)[source]
tests.test_spinner.test_frame_lines_are_what_the_animation_draws(monkeypatch)[source]

A picture of a spinner shows the lines the spinner really writes.

Spins for real, recovers every frame written to the stream, and asserts each one is a line frame_lines() offers. Composing the picture separately from the animation is what lets the two drift the first time the glyph, the label or the timer change places; comparing them is what stops that.

tests.test_spinner.test_frame_lines_honors_reverse()[source]

A spinner cycling backwards is pictured spinning the way it animates.

tests.test_spinner.test_frame_lines_colors_on_request(color)[source]

A capture asks for color whatever stream the spinner would have drawn on.

A spinner that never started resolved no color for itself, so the picture has to state its own answer rather than inherit that one.

tests.test_spinner.test_outcome_leaves_persistent_line(monkeypatch, outcome, glyph, color)[source]
tests.test_spinner.test_ok_degrades_to_plain_line_when_disabled(monkeypatch)[source]

Off a TTY the outcome is still recorded, without symbol color.

tests.test_spinner.test_timer_appended_to_frames_and_final_line()[source]
tests.test_spinner.test_timer_accepts_custom_formatter()[source]

A callable timer formats the elapsed seconds itself (yaspin #236).

tests.test_spinner.test_enable_windows_ansi_is_a_safe_noop()[source]

The Windows VT-enable never raises: off Windows, or on a stream with no usable console handle (the path the spinner exercises on every platform).

tests.test_spinner.test_elapsed_time_freezes_after_stop()[source]
tests.test_spinner.test_catalog_is_complete()[source]

The cli-spinners / ora catalog is present and well-formed.

tests.test_spinner.test_catalog_frames_share_one_width(name)[source]

Every frame of a preset occupies the same number of terminal cells.

A ragged preset moves its label a cell in and out as the animation turns, and a capture laid out on the frames reserves a column for the widest one.

tests.test_spinner.test_catalog_frames_carry_no_upstream_padding(name)[source]

No preset pads every one of its frames with a trailing space.

Upstream writes its emoji frames that way. Kept, the space lands next to the one the spinner writes before its label and reads as a double gap.

tests.test_spinner.test_spinner_preset_supplies_frames_and_interval()[source]
tests.test_spinner.test_explicit_frames_and_interval_override_preset()[source]
tests.test_spinner.test_defaults_without_frames_or_preset()[source]
tests.test_spinner.test_multichar_preset_renders()[source]

A multi-character animation (which upstream \b renderers drop) draws.

tests.test_spinner.test_demo_spinner_table_lists_selection(invoke)[source]

--table prints the catalog table; the tour stays TTY-only.

tests.test_spinner.test_demo_spinner_without_table_flag_shows_no_table(invoke)[source]

Off a TTY and without –table, the command renders no table.

tests.test_spinner.test_demo_spinner_tour_column_shows_three_cycle_time(invoke)[source]

The Tour column reports 3 × frames × interval (dots = 2.4s).

tests.test_spinner.test_demo_spinner_all_lists_full_catalog(invoke)[source]
tests.test_spinner.test_demo_spinner_select_filters_by_name(invoke)[source]
tests.test_spinner.test_demo_spinner_select_rejects_unknown(invoke)[source]
tests.test_spinner.test_demo_spinner_random_limits_count(invoke)[source]
tests.test_spinner.test_demo_spinner_options_are_mutually_exclusive(invoke)[source]
tests.test_spinner.test_tour_duration_bounds_dwell()[source]

The tour dwell aims for three cycles, clamped to [_TOUR_MIN, _TOUR_CAP], and never trims a huge spinner below one full cycle.

tests.test_spinner.test_active_spinner_registry_lifecycle()[source]

A started spinner advertises itself, keyed by stream, until stopped.

tests.test_spinner.test_active_spinner_ignores_disabled_spinner()[source]

A disabled spinner never animates, so it never registers either.

tests.test_spinner.test_trail_glyph(args, kwargs, expected)[source]

The glyph takes a symbol and a style in place of the theme’s.

tests.test_spinner.test_color_resolution_reaches_worker_threads(monkeypatch)[source]

A spinner started on a worker thread sees the invocation’s --no-color.

The thread-local command context is absent there, so the published invocation color is what carries the decision, and it outranks the environment it was reconciled from.

tests.test_spinner.test_resolve_timer_follows_time_flag()[source]

timer=None follows the –time flag; explicit settings pass through.

tests.test_spinner.test_spinner_rejects_invalid_live()[source]

live must be one of WHEN.

tests.test_spinner.test_spinner_timer_follows_time_flag()[source]

A spinner’s default timer follows –time, as a trail’s does.

tests.test_spinner.CUSTOM_CSS = PosixPath('/home/runner/work/click-extra/click-extra/docs/_static/custom.css')

Stylesheet carrying the documentation’s unicode-range declaration.

tests.test_spinner.GRIDLESS_BLOCKS = ((9472, 9599), (9600, 9631), (9632, 9727), (10240, 10495))

Ranges no mainstream monospace font carries a glyph for.

A browser substitutes one that knows nothing of the character grid, so these come out narrow or wide and a captured table’s columns slide apart along the row. docs/_static/custom.css binds a subset font to exactly these.

tests.test_spinner.declared_unicode_ranges()[source]

Read the codepoint spans the documentation’s stylesheet claims.

Return type:

list[tuple[int, int]]

tests.test_spinner.test_catalog_gridless_glyphs_are_covered_by_the_docs_font(invoke)[source]

Every glyph a browser cannot size is one the documentation ships a font for.

The catalog table is laid out on a character grid, and a browser only reproduces that if every glyph advances by one cell. custom.css binds a subset font to the ranges no ordinary monospace font carries; this checks the two have not drifted apart, which they would the moment the declaration is narrowed or a spinner starts drawing from a range it omits.

Note

Narrower than the problem it guards: it checks the ranges already known to need a font, not that a newly used range has been noticed. A spinner drawn from some other gridless block would pass here and still misalign.

tests.test_spinner.SPINNER_ASSETS = PosixPath('/home/runner/work/click-extra/click-extra/docs/assets')

Directory the inventory gallery writes one animation per preset into.

tests.test_spinner.test_every_spinner_has_a_committed_animation()[source]

The inventory gallery covers the catalog exactly, one asset per preset.

The gallery is generated from SPINNERS at build time, so a new preset grows an asset on the next build and this only fails on a committed tree that has fallen behind. The stray half matters more: a renamed or dropped preset leaves its old animation behind, where nothing references it and nothing would notice.