rich_click.testing
Test helpers for CLIs that use Rich for output and prompts.
Classes
| Name | Description |
|---|---|
CliRunner | A drop-in replacement for click.testing.CliRunner that also isolates Rich. |
CliRunnerclass#
class CliRunner(click.testing.CliRunner)Bases: click.testing.CliRunner
A drop-in replacement for click.testing.CliRunner that also isolates Rich.
While a command runs:
- Rich prompts (
rich.prompt.Prompt,rich.prompt.Confirm, andConsole.input()) read from the runner’sinput, including password prompts, which would otherwise callgetpass.getpassand read from the terminal. - Rich’s global console (used by
rich.print()and prompts without an explicit console) is reset in place to follow the runner’scolorsetting, and is not interactive. - Environment variables that change Rich output (
FORCE_COLOR,NO_COLOR,COLUMNS, …) are unset or pinned, unless given inenv.