tests.test_terminal module¶
Tests for click_extra.capture.terminal, which rebuilds a terminal’s screen.
- tests.test_terminal.snapshots(stream)[source]¶
Replay a stream, keeping the screen each redraw leaves behind.
Splitting on the erase-in-line is what a real sampler does with timestamps instead: every animation ends a frame with one.
- tests.test_terminal.replayed(stream, columns=10, rows=4)[source]¶
The text a terminal of that size shows for a stream, unstyled.
The stream is read the way a pseudo-terminal hands it back: a newline moves the cursor straight down, the driver having already added any return.
- Return type:
- tests.test_terminal.test_screen_replays_a_stream(stream, expected)[source]¶
The screen shows what a terminal would, for a stream written in-process.
- tests.test_terminal.test_screen_keeps_a_color_set_between_a_return_and_its_text()[source]¶
A color opened after the cursor comes back wraps the text written over.
An animation writes the return, then its color, then the text, then an erase clearing what is left of the previous frame. The frame must come back in its color, not in the terminal’s default ink.
- tests.test_terminal.test_screen_feeds_the_same_whether_split_or_whole()[source]¶
A stream arriving in pieces lands where the whole of it would.
A recorder reads whatever the terminal hands it, which is not aligned on anything: a frame routinely arrives across two reads.
- tests.test_terminal.test_screen_counts_a_wide_glyph_by_its_cells()[source]¶
A wide glyph covers the two cells it is drawn with.
The count is what says where the cursor stands after it, which is what an erase-in-line acts from.
- tests.test_terminal.test_screen_recovers_every_frame_a_spinner_draws(monkeypatch)[source]¶
Replaying a real spinner’s stream gives back its frames, and only those.
The end of the loop this module exists to close:
frame_lines()says what the spinner draws, the spinner writes it at a terminal, and the screen rebuilds those same lines out of the stream.
- tests.test_terminal.test_screen_replays_a_sized_terminal(stream, expected)[source]¶
A screen of known size follows cursor addressing, wrapping and editing.
One case per control: what xterm shows for the same bytes on a 10 by 4 terminal.
- tests.test_terminal.test_screen_keeps_the_history_a_full_screen_scrolls_away()[source]¶
Rows leaving the top of the first screen stay in the picture.
- tests.test_terminal.test_screen_scrolls_only_its_region()[source]¶
A newline on the last row of a scroll region moves that region alone.
- tests.test_terminal.test_screen_moves_the_region_it_is_given(stream, expected)[source]¶
Scrolling and origin mode answer to the region, not to the whole screen.
- tests.test_terminal.test_screen_draws_a_full_screen_program_on_the_alternate_screen()[source]¶
A full-screen program covers the first screen, which it leaves as it was.
- tests.test_terminal.test_screen_erases_in_the_background_in_force()[source]¶
An erase paints the cells it clears, which is how a bar is drawn.
xterm calls this background color erase,
bce, and its terminfo entry tellsncursesto rely on it.
- tests.test_terminal.test_screen_blanks_the_half_a_write_leaves_of_a_wide_glyph()[source]¶
Overwriting one cell of a wide glyph leaves a blank in the other.
- tests.test_terminal.test_screen_joins_a_combining_mark_to_its_base()[source]¶
A combining accent arriving in its own read still lands on its letter.
- tests.test_terminal.test_screen_reads_a_color_in_both_spellings()[source]¶
A 24-bit color reads the same written with semicolons or with colons.
- tests.test_terminal.test_screen_reports_the_modes_a_recording_reads()[source]¶
Cursor visibility and synchronized updates are exposed, not drawn.
- tests.test_terminal.test_screen_resets_to_its_starting_state()[source]¶
A full reset clears the screen and every mode.
- tests.test_terminal.test_screen_skips_a_runaway_string_to_its_terminator()[source]¶
A string longer than the pending limit is skipped, never drawn.
- tests.test_terminal.test_screen_skips_a_runaway_string_cut_inside_its_terminator()[source]¶
The read that starts skipping a string can end on its terminator’s escape.
- tests.test_terminal.INFOCMP = '/usr/bin/infocmp'¶
The terminfo dumper
ncursesships, listing the capabilities of an entry.
- tests.test_terminal.TERMINAL_REPLIES = frozenset({'rv', 'u6', 'u8', 'xr'})¶
Capabilities describing what a terminal answers to a query.
u6andu8give the format of the cursor position and device attributes replies,rvandxrthe patterns of the version replies.ncursesmatches them against what comes back from the terminal, the way it matches a key capability against what the keyboard sends: no program writes them.
- tests.test_terminal.TERMINFO_PADDING_RE = re.compile(b'\\$<[\\d.*/]+>')¶
A delay a terminfo capability asks for, which
tputswaits out rather than sending, like the$<100/>of xterm’s visible bell.
- tests.test_terminal.test_screen_reads_every_sequence_of_the_recording_terminal()[source]¶
No capability of
xterm-256colorlands on the screen as text.The terminal a recording names to its command decides what the command writes, so every string capability of that entry is fed to the screen, parameters filled in, and followed by one letter: only that letter may show. A sequence the screen failed to recognize would leave its bytes behind, the way
ESC [ ? 1049 hwould print[?1049h.