Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/tutorial/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@ If you need a refresher about what is "standard output" and "standard error" che

///

#### Checking rich output

Rich attempts to adjust the formatting to the connected terminal's size, wrapping or shortening content to make it fit.
However, in many test environments, there is no terminal attached to the process, and therefore Rich will fallback to a standard terminal width of 80 characters.

In some cases this might not be sufficient to test the output of a command.
It is possible to override the width of a Rich `Console` object using the environment variable `COLUMNS`.
This applies to all instances of a console created in the application.

Typer also creates such an instance, which is used for output produced by Typer, such as the help display.
The terminal width of this console can be forced using the environment variable `TERMINAL_WIDTH`.

/// tip

It is necessary to set these variables *before* importing a Typer app for testing.

///

### Call `pytest`

Then you can call `pytest` in your directory and it will run your tests:
Expand Down